Skip to content

Commit

Permalink
identify: fix flaky TestIdentifyDeltaOnProtocolChange (again) (#1582)
Browse files Browse the repository at this point in the history
We can get events happening as soon as we connect and if subscribe after
we started the connection, then we could miss these events.
  • Loading branch information
MarcoPolo committed Jun 24, 2022
1 parent 30e2d0e commit 3af7820
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions p2p/protocol/identify/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,17 @@ func TestIdentifyDeltaOnProtocolChange(t *testing.T) {
ids2.Close()
}()

if err := h1.Connect(ctx, peer.AddrInfo{ID: h2.ID(), Addrs: h2.Addrs()}); err != nil {
t.Fatal(err)
}

idComplete, err := h1.EventBus().Subscribe(&event.EvtPeerIdentificationCompleted{})
require.NoError(t, err)
defer idComplete.Close()
idFailed, err := h1.EventBus().Subscribe(&event.EvtPeerIdentificationFailed{})
require.NoError(t, err)
defer idFailed.Close()

if err := h1.Connect(ctx, peer.AddrInfo{ID: h2.ID(), Addrs: h2.Addrs()}); err != nil {
t.Fatal(err)
}

conn := h1.Network().ConnsToPeer(h2.ID())[0]
select {
case <-ids1.IdentifyWait(conn):
Expand Down

0 comments on commit 3af7820

Please sign in to comment.