Skip to content
Snippets Groups Projects
Unverified Commit b8c48b20 authored by Wolfgang Welz's avatar Wolfgang Welz Committed by GitHub
Browse files

Fix: Deadlock in TestDropNeighbor (#362)

parent ca1d9f1d
Branches
Tags
No related merge requests found
...@@ -387,7 +387,7 @@ func TestDropNeighbor(t *testing.T) { ...@@ -387,7 +387,7 @@ func TestDropNeighbor(t *testing.T) {
go func() { assert.NoError(t, mgrA.AddInbound(peerB)) }() go func() { assert.NoError(t, mgrA.AddInbound(peerB)) }()
go func() { assert.NoError(t, mgrB.AddOutbound(peerA)) }() go func() { assert.NoError(t, mgrB.AddOutbound(peerA)) }()
wg.Wait() // wait until the events were triggered wg.Wait() // wait until the events were triggered and the peers are connected
} }
disc := func() { disc := func() {
var wg sync.WaitGroup var wg sync.WaitGroup
...@@ -396,9 +396,17 @@ func TestDropNeighbor(t *testing.T) { ...@@ -396,9 +396,17 @@ func TestDropNeighbor(t *testing.T) {
Events.NeighborRemoved.Attach(closure) Events.NeighborRemoved.Attach(closure)
defer Events.NeighborRemoved.Detach(closure) defer Events.NeighborRemoved.Detach(closure)
go func() { _ = mgrA.DropNeighbor(peerB.ID()) }() // assure that no DropNeighbor calls are leaking
go func() { _ = mgrB.DropNeighbor(peerA.ID()) }() wg.Add(2)
wg.Wait() // wait until the events were triggered go func() {
defer wg.Done()
_ = mgrA.DropNeighbor(peerB.ID())
}()
go func() {
defer wg.Done()
_ = mgrB.DropNeighbor(peerA.ID())
}()
wg.Wait() // wait until the events were triggered and the go routines are done
} }
// drop and connect many many times // drop and connect many many times
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment