identify: fix flaky TestIdentifyDeltaOnProtocolChange (again)
We can get events happening as soon as we connect and if subscribe after
we started the connection, then we could miss these events.
@@ -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):
