From dafc4faee5a3de40eabf97ecf4a80e7e06c2d420 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Fri, 22 Apr 2022 22:48:30 +0100 Subject: [PATCH] quic: fix flaky TestConnectionGating test --- p2p/transport/quic/conn_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/p2p/transport/quic/conn_test.go b/p2p/transport/quic/conn_test.go index 2d789a956c..8a148f5d94 100644 --- a/p2p/transport/quic/conn_test.go +++ b/p2p/transport/quic/conn_test.go @@ -303,9 +303,11 @@ func TestConnectionGating(t *testing.T) { defer clientTransport.(io.Closer).Close() // make sure that connection attempts fails conn, err := clientTransport.Dial(context.Background(), ln.Multiaddr(), serverID) - require.NoError(t, err) - _, err = conn.AcceptStream() - require.Error(t, err) + // In rare instances, the connection gating error will already occur on Dial. + // In most cases, it will be returned by AcceptStream. + if err == nil { + _, err = conn.AcceptStream() + } require.Contains(t, err.Error(), "connection gated") // now allow the address and make sure the connection goes through