Skip to content

Commit

Permalink
bitswap_test: make racy test less racy
Browse files Browse the repository at this point in the history
fixes #4108

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
  • Loading branch information
Stebalien committed Jul 31, 2017
1 parent 8ad3b11 commit f613fba
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions exchange/bitswap/bitswap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,26 @@ func TestBasicBitswap(t *testing.T) {
t.Fatal(err)
}

time.Sleep(time.Millisecond * 25)
wl := instances[2].Exchange.WantlistForPeer(instances[1].Peer)
if len(wl) != 0 {
t.Fatal("should have no items in other peers wantlist")
check := func() error {
if len(instances[2].Exchange.WantlistForPeer(instances[1].Peer)) != 0 {
return fmt.Errorf("should have no items in other peers wantlist")
}

if len(instances[1].Exchange.GetWantlist()) != 0 {
return fmt.Errorf("shouldnt have anything in wantlist")
}
return nil
}
if len(instances[1].Exchange.GetWantlist()) != 0 {
t.Fatal("shouldnt have anything in wantlist")

for {
time.Sleep(time.Millisecond * 10)
if err := check(); err != nil {
if ctx.Err() != nil {
t.Fatal(err)
}
} else {
break
}
}

st0, err := instances[0].Exchange.Stat()
Expand Down

0 comments on commit f613fba

Please sign in to comment.