Merge pull request #46 from libp2p/rcmgr

add mocks for the resource manager
This commit is contained in:
Marten Seemann 2022-01-16 23:51:13 -08:00 committed by GitHub
commit a1aa7d3db6
1 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@ import (
crand "crypto/rand" crand "crypto/rand"
mrand "math/rand" mrand "math/rand"
"github.com/libp2p/go-libp2p-core/mux" "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/transport" "github.com/libp2p/go-libp2p-core/transport"
"github.com/libp2p/go-libp2p-testing/race" "github.com/libp2p/go-libp2p-testing/race"
@ -53,7 +53,7 @@ type Options struct {
MsgMax int MsgMax int
} }
func fullClose(t *testing.T, s mux.MuxedStream) { func fullClose(t *testing.T, s network.MuxedStream) {
if err := s.CloseWrite(); err != nil { if err := s.CloseWrite(); err != nil {
t.Error(err) t.Error(err)
s.Reset() s.Reset()
@ -87,7 +87,7 @@ func debugLog(t *testing.T, s string, args ...interface{}) {
} }
} }
func echoStream(t *testing.T, s mux.MuxedStream) { func echoStream(t *testing.T, s network.MuxedStream) {
// echo everything // echo everything
var err error var err error
if VerboseDebugging { if VerboseDebugging {
@ -164,7 +164,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
rateLimitChan <- struct{}{} rateLimitChan <- struct{}{}
} }
writeStream := func(s mux.MuxedStream, bufs chan<- []byte) { writeStream := func(s network.MuxedStream, bufs chan<- []byte) {
debugLog(t, "writeStream %p, %d MsgNum", s, opt.MsgNum) debugLog(t, "writeStream %p, %d MsgNum", s, opt.MsgNum)
for i := 0; i < opt.MsgNum; i++ { for i := 0; i < opt.MsgNum; i++ {
@ -178,7 +178,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
} }
} }
readStream := func(s mux.MuxedStream, bufs <-chan []byte) { readStream := func(s network.MuxedStream, bufs <-chan []byte) {
debugLog(t, "readStream %p, %d MsgNum", s, opt.MsgNum) debugLog(t, "readStream %p, %d MsgNum", s, opt.MsgNum)
buf2 := make([]byte, msgsize) buf2 := make([]byte, msgsize)
@ -198,7 +198,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr,
} }
} }
openStreamAndRW := func(c mux.MuxedConn) { openStreamAndRW := func(c network.MuxedConn) {
debugLog(t, "openStreamAndRW %p, %d opt.MsgNum", c, opt.MsgNum) debugLog(t, "openStreamAndRW %p, %d opt.MsgNum", c, opt.MsgNum)
s, err := c.OpenStream(context.Background()) s, err := c.OpenStream(context.Background())