Commit 3952e601 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

op-e2e: Fix hanging network notify test (#12868)

parent b1efd7c5
......@@ -360,18 +360,24 @@ func TestNetworkNotifyAddPeerAndRemovePeer(t *testing.T) {
return nil
}, metrics.NoopMetrics, &NoopApplicationScorer{})
waitChan := make(chan struct{}, 1)
waitChan := make(chan struct{}, 2)
var connectedOnce sync.Once
var disconnectedOnce sync.Once
hostA.Network().Notify(&network.NotifyBundle{
ConnectedF: func(nw network.Network, conn network.Conn) {
syncCl.AddPeer(conn.RemotePeer())
waitChan <- struct{}{}
connectedOnce.Do(func() {
syncCl.AddPeer(conn.RemotePeer())
waitChan <- struct{}{}
})
},
DisconnectedF: func(nw network.Network, conn network.Conn) {
// only when no connection is available, we can remove the peer
if nw.Connectedness(conn.RemotePeer()) == network.NotConnected {
syncCl.RemovePeer(conn.RemotePeer())
}
waitChan <- struct{}{}
disconnectedOnce.Do(func() {
// only when no connection is available, we can remove the peer
if nw.Connectedness(conn.RemotePeer()) == network.NotConnected {
syncCl.RemovePeer(conn.RemotePeer())
}
waitChan <- struct{}{}
})
},
})
syncCl.Start()
......
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