1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 01:52:26 +08:00

fixing race in swarm

This commit is contained in:
Juan Batiz-Benet
2014-12-23 17:59:24 -08:00
parent 32589ad4bb
commit fd2875f2ed

View File

@ -248,15 +248,21 @@ func TestConnHandler(t *testing.T) {
<-time.After(time.Millisecond)
// should've gotten 5 by now.
close(gotconn)
swarms[0].SetConnHandler(nil)
expect := 4
actual := 0
for _ = range gotconn {
actual++
for i := 0; i < expect; i++ {
select {
case <-time.After(time.Second):
t.Fatal("failed to get connections")
case <-gotconn:
}
}
if actual != expect {
t.Fatal("should have connected to %d swarms. got: %d", actual, expect)
select {
case <-gotconn:
t.Fatalf("should have connected to %d swarms", expect)
default:
}
}