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:
@ -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:
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user