fix flaky TestResourceManagerAcceptStream test (#1420)

This commit is contained in:
Marten Seemann 2022-04-22 15:51:26 +01:00 committed by GitHub
parent e28b91aa2b
commit 37f58509c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -534,8 +534,11 @@ func TestResourceManagerAcceptStream(t *testing.T) {
rcmgr2.EXPECT().OpenStream(s1.LocalPeer(), network.DirInbound).Return(nil, errors.New("nope"))
str, err := s1.NewStream(context.Background(), s2.LocalPeer())
require.NoError(t, err)
// The peer's resource manager is blocking any new stream.
// Depending on how quickly we receive the stream reset, it surfaces either during the write or the read call.
_, err = str.Write([]byte("foobar"))
require.NoError(t, err)
_, err = str.Read([]byte{0})
if err == nil {
_, err = str.Read([]byte{0})
}
require.EqualError(t, err, "stream reset")
}