From d55bbc00c48dd0b4945262ab9838e7c999bf7df1 Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Tue, 31 May 2022 16:27:28 -0700 Subject: [PATCH] Subscribe to events before we connect We can get events happening as soon as we connect and if subscribe after we started the connection, then we could miss these events. --- p2p/protocol/identify/id_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/p2p/protocol/identify/id_test.go b/p2p/protocol/identify/id_test.go index a82497c3d3..cc809e1e90 100644 --- a/p2p/protocol/identify/id_test.go +++ b/p2p/protocol/identify/id_test.go @@ -373,10 +373,6 @@ 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() @@ -384,6 +380,10 @@ func TestIdentifyDeltaOnProtocolChange(t *testing.T) { 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):