Commit 1cef084e authored by Juan Batiz-Benet's avatar Juan Batiz-Benet
Browse files

mock: fix notif test



License: MIT
Signed-off-by: default avatarJuan Batiz-Benet <juan@benet.ai>
parent 19f33952
...@@ -43,24 +43,30 @@ func TestNotifications(t *testing.T) { ...@@ -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++ {
var c inet.Conn
select { select {
case c = <-n.connected: case c := <-n.connected:
actual = append(actual, c)
case <-time.After(timeout): case <-time.After(timeout):
t.Fatal("timeout") t.Fatal("timeout")
} }
for _, c2 := range cos { }
if c == c2 {
t.Log("got notif for conn") expect := s.ConnsToPeer(s2.LocalPeer())
return for _, c1 := range actual {
found := false
for _, c2 := range expect {
if c1 == c2 {
found = true
break
} }
} }
if !found {
t.Error("connection not found") t.Error("connection not found")
} }
}() }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment