-
Notifications
You must be signed in to change notification settings - Fork 12
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
Defer closing stream for reading #32
Conversation
f2de233
to
e24c08f
Compare
suites/transport/transport_suite.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a one-line if.
suites/transport/transport_suite.go
Outdated
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
suites/transport/transport_suite.go
Outdated
@@ -265,7 +271,11 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd | |||
t.Error("failed to write enough data (a->b)") | |||
return | |||
} | |||
s.Close() | |||
err = s.CloseWrite() | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and here.
suites/transport/transport_suite.go
Outdated
@@ -276,6 +286,12 @@ func SubtestPingPong(t *testing.T, ta, tb transport.Transport, maddr ma.Multiadd | |||
if !bytes.Equal(data, ret) { | |||
t.Errorf("expected %q, got %q", string(data), string(ret)) | |||
} | |||
|
|||
err = s.Close() | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here.
Hey there,
I'm trying to bring https://github.com/mtojek/go-libp2p-webrtc-star up to date (fork) and now with updated dependencies, the transport test suite is failing.
I had a look at the test cases and noticed that there are reading attempts on already closed streams. I guess this wasn't a problem until go-libp2p v0.12.0:
In this PR I just deferred closing the reading side.