From af24f73bb3d17bfa330a699a5154109c275dd3df Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 18 Sep 2021 21:20:11 +0100 Subject: [PATCH] fix flaky TestEndToEndSimConnect holepunching test --- p2p/protocol/holepunch/coordination_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/p2p/protocol/holepunch/coordination_test.go b/p2p/protocol/holepunch/coordination_test.go index c314e17b30..e7509daecd 100644 --- a/p2p/protocol/holepunch/coordination_test.go +++ b/p2p/protocol/holepunch/coordination_test.go @@ -102,8 +102,15 @@ func TestEndToEndSimConnect(t *testing.T) { ensureDirectConn(t, h1, h2) // ensure no hole-punching streams are open on either side ensureNoHolePunchingStream(t, h1, h2) - events := tr.getEvents() - require.Len(t, events, 3) + var events []*holepunch.Event + require.Eventually(t, + func() bool { + events = tr.getEvents() + return len(events) == 3 + }, + time.Second, + 10*time.Millisecond, + ) require.Equal(t, events[0].Type, holepunch.StartHolePunchEvtT) require.Equal(t, events[1].Type, holepunch.HolePunchAttemptEvtT) require.Equal(t, events[2].Type, holepunch.EndHolePunchEvtT)