Skip to content

Commit

Permalink
test: fix flaky tests
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-bitswap@3be2da8
  • Loading branch information
dirkmc committed Mar 4, 2020
1 parent c596d1b commit 09ec5df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions bitswap/internal/messagequeue/messagequeue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ func TestWantlistRebroadcast(t *testing.T) {
t.Fatal("wrong number of wants")
}

// Tell message queue to rebroadcast after 5ms, then wait 8ms
messageQueue.SetRebroadcastInterval(5 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 8*time.Millisecond)
// Tell message queue to rebroadcast after 10ms, then wait 15ms
messageQueue.SetRebroadcastInterval(10 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 15*time.Millisecond)
firstMessage = messages[0]

// Both original and new wants should have been rebroadcast
Expand Down Expand Up @@ -425,9 +425,9 @@ func TestWantlistRebroadcast(t *testing.T) {
}
}

// Tell message queue to rebroadcast after 5ms, then wait 8ms
messageQueue.SetRebroadcastInterval(5 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 8*time.Millisecond)
// Tell message queue to rebroadcast after 10ms, then wait 15ms
messageQueue.SetRebroadcastInterval(10 * time.Millisecond)
messages = collectMessages(ctx, t, messagesSent, 15*time.Millisecond)
firstMessage = messages[0]
if len(firstMessage.Wantlist()) != totalWants-len(cancels) {
t.Fatal("did not rebroadcast all wants")
Expand Down
6 changes: 3 additions & 3 deletions bitswap/internal/session/sessionwantsender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func TestConsecutiveDontHaveLimit(t *testing.T) {
spm.Update(p, []cid.Cid{}, cids[:1], []cid.Cid{})

// Wait for processing to complete
time.Sleep(5 * time.Millisecond)
time.Sleep(10 * time.Millisecond)

// Peer should be available
if has := fpm.HasPeer(p); !has {
Expand All @@ -495,7 +495,7 @@ func TestConsecutiveDontHaveLimit(t *testing.T) {
}

// Wait for processing to complete
time.Sleep(5 * time.Millisecond)
time.Sleep(20 * time.Millisecond)

// Peer should be available
if has := fpm.HasPeer(p); !has {
Expand All @@ -509,7 +509,7 @@ func TestConsecutiveDontHaveLimit(t *testing.T) {
}

// Wait for processing to complete
time.Sleep(5 * time.Millisecond)
time.Sleep(20 * time.Millisecond)

// Session should remove peer
if has := fpm.HasPeer(p); has {
Expand Down

0 comments on commit 09ec5df

Please sign in to comment.