1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-30 09:59:13 +08:00

mock: fix notif test

License: MIT
Signed-off-by: Juan Batiz-Benet <juan@benet.ai>
This commit is contained in:
Juan Batiz-Benet
2015-06-26 23:57:01 -07:00
parent 6b8e9f51fe
commit f796615e10

View File

@ -43,24 +43,30 @@ func TestNotifications(t *testing.T) {
for i, s := range nets { for i, s := range nets {
n := notifiees[i] n := notifiees[i]
for _, s2 := range nets { for _, s2 := range nets {
cos := s.ConnsToPeer(s2.LocalPeer()) var actual []inet.Conn
func() { for len(s.ConnsToPeer(s2.LocalPeer())) != len(actual) {
for i := 0; i < len(cos); i++ { select {
var c inet.Conn case c := <-n.connected:
select { actual = append(actual, c)
case c = <-n.connected: case <-time.After(timeout):
case <-time.After(timeout): t.Fatal("timeout")
t.Fatal("timeout") }
} }
for _, c2 := range cos {
if c == c2 { expect := s.ConnsToPeer(s2.LocalPeer())
t.Log("got notif for conn") for _, c1 := range actual {
return found := false
} for _, c2 := range expect {
if c1 == c2 {
found = true
break
} }
}
if !found {
t.Error("connection not found") t.Error("connection not found")
} }
}() }
} }
} }