Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-mplex
Commits
b10cf5ef
Unverified
Commit
b10cf5ef
authored
May 23, 2019
by
Steven Allen
Committed by
GitHub
May 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #60 from libp2p/fix/deadlines
add test for deadlines
parents
fd72cdc0
50a8f1b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
+52
-0
multiplex_test.go
multiplex_test.go
+52
-0
No files found.
multiplex_test.go
View file @
b10cf5ef
...
...
@@ -429,6 +429,58 @@ func TestOpenAfterClose(t *testing.T) {
mpb
.
Close
()
}
func
TestDeadline
(
t
*
testing
.
T
)
{
a
,
b
:=
net
.
Pipe
()
mpa
:=
NewMultiplex
(
a
,
false
)
mpb
:=
NewMultiplex
(
b
,
true
)
defer
mpa
.
Close
()
defer
mpb
.
Close
()
sa
,
err
:=
mpa
.
NewStream
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
_
,
err
=
mpb
.
Accept
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
sa
.
SetDeadline
(
time
.
Now
()
.
Add
(
time
.
Second
))
_
,
err
=
sa
.
Read
(
make
([]
byte
,
1024
))
if
err
!=
errTimeout
{
t
.
Fatal
(
"expected timeout"
)
}
}
func
TestReadAfterClose
(
t
*
testing
.
T
)
{
a
,
b
:=
net
.
Pipe
()
mpa
:=
NewMultiplex
(
a
,
false
)
mpb
:=
NewMultiplex
(
b
,
true
)
defer
mpa
.
Close
()
defer
mpb
.
Close
()
sa
,
err
:=
mpa
.
NewStream
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
sb
,
err
:=
mpb
.
Accept
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
sa
.
Close
()
_
,
err
=
sb
.
Read
(
make
([]
byte
,
1024
))
if
err
!=
io
.
EOF
{
t
.
Fatal
(
"expected EOF"
)
}
}
func
TestFuzzCloseStream
(
t
*
testing
.
T
)
{
timer
:=
time
.
AfterFunc
(
10
*
time
.
Second
,
func
()
{
// This is really the *only* reliable way to set a timeout on
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment