Skip to content

Commit

Permalink
mock: fix notif test
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
  • Loading branch information
jbenet committed Jun 27, 2015
1 parent 6b8e9f5 commit f796615
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions p2p/net/mock/mock_notif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,30 @@ func TestNotifications(t *testing.T) {
for i, s := range nets {
n := notifiees[i]
for _, s2 := range nets {
cos := s.ConnsToPeer(s2.LocalPeer())
func() {
for i := 0; i < len(cos); i++ {
var c inet.Conn
select {
case c = <-n.connected:
case <-time.After(timeout):
t.Fatal("timeout")
}
for _, c2 := range cos {
if c == c2 {
t.Log("got notif for conn")
return
}
var actual []inet.Conn
for len(s.ConnsToPeer(s2.LocalPeer())) != len(actual) {
select {
case c := <-n.connected:
actual = append(actual, c)
case <-time.After(timeout):
t.Fatal("timeout")
}
}

expect := s.ConnsToPeer(s2.LocalPeer())
for _, c1 := range actual {
found := false
for _, c2 := range expect {
if c1 == c2 {
found = true
break
}
}
if !found {
t.Error("connection not found")
}
}()
}

}
}

Expand Down

0 comments on commit f796615

Please sign in to comment.