Merge pull request #1461 from libp2p/fix-flaky-quic-rcmgr-accept-test

quic: fix flaky TestResourceManagerAcceptDenied
This commit is contained in:
Steven Allen 2022-05-03 12:57:32 -04:00 committed by GitHub
commit 7bfde91b34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -198,9 +198,13 @@ func TestResourceManagerAcceptDenied(t *testing.T) {
clientRcmgr.EXPECT().OpenConnection(network.DirOutbound, false).Return(clientConnScope, nil)
clientConnScope.EXPECT().SetPeer(serverID)
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.
if err != nil {
clientConnScope.EXPECT().Done()
} else {
_, err = conn.AcceptStream()
require.Error(t, err)
}
select {
case <-connChan:
t.Fatal("didn't expect to accept a connection")