Skip to content

Commit

Permalink
Use lower limits for the listener
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoPolo committed Aug 16, 2023
1 parent aff1115 commit 22b5161
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions p2p/test/transport/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/network"
"github.com/libp2p/go-libp2p/core/peer"
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
"github.com/libp2p/go-libp2p/p2p/muxer/yamux"
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
"github.com/libp2p/go-libp2p/p2p/security/noise"
Expand Down Expand Up @@ -357,7 +358,16 @@ func TestMoreStreamsThanOurLimits(t *testing.T) {
const streamCount = 1024
for _, tc := range transportsToTest {
t.Run(tc.Name, func(t *testing.T) {
listener := tc.HostGenerator(t, TransportTestCaseOpts{})
listenerLimits := rcmgr.PartialLimitConfig{
PeerDefault: rcmgr.ResourceLimits{
Streams: 32,
StreamsInbound: 16,
StreamsOutbound: 16,
},
}
r, err := rcmgr.NewResourceManager(rcmgr.NewFixedLimiter(listenerLimits.Build(rcmgr.DefaultLimits.AutoScale())))
require.NoError(t, err)
listener := tc.HostGenerator(t, TransportTestCaseOpts{ResourceManager: r})
dialer := tc.HostGenerator(t, TransportTestCaseOpts{NoListen: true, NoRcmgr: true})
defer listener.Close()
defer dialer.Close()
Expand Down Expand Up @@ -495,7 +505,7 @@ func TestMoreStreamsThanOurLimits(t *testing.T) {

require.NoError(t, <-errCh)
require.Equal(t, streamCount, int(handledStreams.Load()))
require.True(t, sawFirstErr.Load())
require.True(t, sawFirstErr.Load(), "Expected to see an error from the peer")
})
}
}
Expand Down

0 comments on commit 22b5161

Please sign in to comment.