From f2de233a81f202db3b4f91e2f2f7f0e496a8c3ae Mon Sep 17 00:00:00 2001 From: Dennis Trautwein Date: Sat, 1 May 2021 16:52:33 +0200 Subject: [PATCH] Defer closing stream for reading --- suites/transport/stream_suite.go | 5 ++++- suites/transport/transport_suite.go | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/suites/transport/stream_suite.go b/suites/transport/stream_suite.go index f7172b4..b1db0bc 100644 --- a/suites/transport/stream_suite.go +++ b/suites/transport/stream_suite.go @@ -55,7 +55,7 @@ type Options struct { } func fullClose(t *testing.T, s mux.MuxedStream) { - if err := s.Close(); err != nil { + if err := s.CloseWrite(); err != nil { t.Error(err) s.Reset() return @@ -67,6 +67,9 @@ func fullClose(t *testing.T, s mux.MuxedStream) { if len(b) != 0 { t.Error("expected to be done reading") } + if err := s.Close(); err != nil { + t.Error(err) + } } func randBuf(size int) []byte { diff --git a/suites/transport/transport_suite.go b/suites/transport/transport_suite.go index 234c43c..ae86a24 100644 --- a/suites/transport/transport_suite.go +++ b/suites/transport/transport_suite.go @@ -141,7 +141,7 @@ func SubtestBasic(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, t.Fatalf("failed to write enough data (a->b)") return } - err = s.Close() + err = s.CloseWrite() if err != nil { t.Fatal(err) return @@ -155,6 +155,12 @@ func SubtestBasic(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, if !bytes.Equal(testData, buf) { t.Errorf("expected %s, got %s", testData, buf) } + + err = s.Close() + if err != nil { + t.Fatal(err) + return + } } func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiaddr, peerA peer.ID) {