Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix flaky TestResourceManagerAcceptStream test #1420

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions p2p/net/swarm/swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}