From 350de6acf3330eba991a28066732bde0d4aa02eb Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 17 Dec 2020 16:42:55 +0700 Subject: [PATCH] pass contexts to OpenStream in tests --- go.mod | 2 +- go.sum | 4 ++-- suites/mux/muxer_suite.go | 9 +++++---- suites/transport/stream_suite.go | 6 +++--- suites/transport/transport_suite.go | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index da3dd4d..321ce5a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/libp2p/go-libp2p-testing go 1.12 require ( - github.com/libp2p/go-libp2p-core v0.7.0 + github.com/libp2p/go-libp2p-core v0.8.0 github.com/multiformats/go-multiaddr v0.3.1 go.uber.org/atomic v1.6.0 google.golang.org/grpc v1.31.1 diff --git a/go.sum b/go.sum index 5fbebbb..0a84a9c 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,8 @@ github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6 github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/libp2p/go-flow-metrics v0.0.3/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs= -github.com/libp2p/go-libp2p-core v0.7.0 h1:4a0TMjrWNTZlNvcqxZmrMRDi/NQWrhwO2pkTuLSQ/IQ= -github.com/libp2p/go-libp2p-core v0.7.0/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= +github.com/libp2p/go-libp2p-core v0.8.0 h1:5K3mT+64qDTKbV3yTdbMCzJ7O6wbNsavAEb8iqBvBcI= +github.com/libp2p/go-libp2p-core v0.8.0/go.mod h1:FfewUH/YpvWbEB+ZY9AQRQ4TAD8sJBt/G1rVvhz5XT8= github.com/libp2p/go-maddr-filter v0.1.0/go.mod h1:VzZhTXkMucEGGEOSKddrwGiOv0tUhgnKqNEmIAz/bPU= github.com/libp2p/go-msgio v0.0.6/go.mod h1:4ecVB6d9f4BDSL5fqvPiC4A3KivjWn+Venn/1ALLMWA= github.com/libp2p/go-openssl v0.0.7 h1:eCAzdLejcNVBzP/iZM9vqHnQm+XyCEbSSIheIPRGNsw= diff --git a/suites/mux/muxer_suite.go b/suites/mux/muxer_suite.go index 2b42b77..5709f22 100644 --- a/suites/mux/muxer_suite.go +++ b/suites/mux/muxer_suite.go @@ -2,6 +2,7 @@ package test import ( "bytes" + "context" "fmt" "io" "net" @@ -138,7 +139,7 @@ func SubtestSimpleWrite(t *testing.T, tr mux.Multiplexer) { go c1.AcceptStream() log("creating stream") - s1, err := c1.OpenStream() + s1, err := c1.OpenStream(context.Background()) checkErr(t, err) defer s1.Close() @@ -211,7 +212,7 @@ func SubtestStress(t *testing.T, opt Options) { openStreamAndRW := func(c mux.MuxedConn) { log("openStreamAndRW %p, %d opt.msgNum", c, opt.msgNum) - s, err := c.OpenStream() + s, err := c.OpenStream(context.Background()) if err != nil { errs <- fmt.Errorf("Failed to create NewStream: %s", err) return @@ -339,7 +340,7 @@ func SubtestStreamOpenStress(t *testing.T, tr mux.Multiplexer) { stress := func() { defer wg.Done() for i := 0; i < count; i++ { - s, err := muxa.OpenStream() + s, err := muxa.OpenStream(context.Background()) if err != nil { t.Error(err) return @@ -422,7 +423,7 @@ func SubtestStreamReset(t *testing.T, tr mux.Multiplexer) { t.Error(err) return } - s, err := muxa.OpenStream() + s, err := muxa.OpenStream(context.Background()) if err != nil { t.Error(err) return diff --git a/suites/transport/stream_suite.go b/suites/transport/stream_suite.go index e04deae..f7172b4 100644 --- a/suites/transport/stream_suite.go +++ b/suites/transport/stream_suite.go @@ -206,7 +206,7 @@ func SubtestStress(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, openStreamAndRW := func(c mux.MuxedConn) { debugLog(t, "openStreamAndRW %p, %d opt.MsgNum", c, opt.MsgNum) - s, err := c.OpenStream() + s, err := c.OpenStream(context.Background()) if err != nil { errs <- fmt.Errorf("Failed to create NewStream: %s", err) return @@ -329,7 +329,7 @@ func SubtestStreamOpenStress(t *testing.T, ta, tb transport.Transport, maddr ma. go func() { defer wg.Done() for i := 0; i < count; i++ { - s, err := connA.OpenStream() + s, err := connA.OpenStream(context.Background()) if err != nil { t.Error(err) return @@ -384,7 +384,7 @@ func SubtestStreamReset(t *testing.T, ta, tb transport.Transport, maddr ma.Multi muxa, err := l.Accept() checkErr(t, err) - s, err := muxa.OpenStream() + s, err := muxa.OpenStream(context.Background()) if err != nil { panic(err) } diff --git a/suites/transport/transport_suite.go b/suites/transport/transport_suite.go index eef75bf..234c43c 100644 --- a/suites/transport/transport_suite.go +++ b/suites/transport/transport_suite.go @@ -126,7 +126,7 @@ func SubtestBasic(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, t.Fatal(err) } - s, err := connA.OpenStream() + s, err := connA.OpenStream(context.Background()) if err != nil { t.Fatal(err) } @@ -243,7 +243,7 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd } for i := 0; i < streams; i++ { - s, err := connB.OpenStream() + s, err := connB.OpenStream(context.Background()) if err != nil { t.Error(err) continue