Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5cbfb6e

Browse files
committedJun 27, 2015
fix swarm notif tests
they were failing intermittently License: MIT Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
1 parent f796615 commit 5cbfb6e

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed
 

‎p2p/net/swarm/swarm_notif_test.go

+22-16
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,30 @@ func TestNotifications(t *testing.T) {
4444
continue
4545
}
4646

47-
cos := s.ConnectionsToPeer(s2.LocalPeer())
48-
func() {
49-
for i := 0; i < len(cos); i++ {
50-
var c inet.Conn
51-
select {
52-
case c = <-n.connected:
53-
case <-time.After(timeout):
54-
t.Fatal("timeout")
55-
}
56-
for _, c2 := range cos {
57-
if c == c2 {
58-
t.Log("got notif for conn", c)
59-
return
60-
}
47+
var actual []inet.Conn
48+
for len(s.ConnectionsToPeer(s2.LocalPeer())) != len(actual) {
49+
select {
50+
case c := <-n.connected:
51+
actual = append(actual, c)
52+
case <-time.After(timeout):
53+
t.Fatal("timeout")
54+
}
55+
}
56+
57+
expect := s.ConnectionsToPeer(s2.LocalPeer())
58+
for _, c1 := range actual {
59+
found := false
60+
for _, c2 := range expect {
61+
if c1 == c2 {
62+
found = true
63+
break
6164
}
62-
t.Error("connection not found", c)
6365
}
64-
}()
66+
if !found {
67+
t.Error("connection not found")
68+
}
69+
}
70+
6571
}
6672
}
6773

‎p2p/net/swarm/swarm_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,6 @@ func TestFilterBounds(t *testing.T) {
325325
case <-time.After(time.Second):
326326
t.Fatal("should have gotten connection")
327327
case <-conns:
328-
fmt.Println("got connect")
328+
t.Log("got connect")
329329
}
330330
}

0 commit comments

Comments
 (0)
Please sign in to comment.