From 3af782039ae903f4fa2fc9dbfe54281992f8a75f Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Wed, 1 Jun 2022 01:45:48 -0700 Subject: [PATCH] identify: fix flaky TestIdentifyDeltaOnProtocolChange (again) (#1582) 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):