Skip to content

Commit

Permalink
add deadline test
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed May 22, 2019
1 parent 8df7f3d commit 8917d60
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions multiplex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,32 @@ 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 TestFuzzCloseStream(t *testing.T) {
timer := time.AfterFunc(10*time.Second, func() {
// This is really the *only* reliable way to set a timeout on
Expand Down

0 comments on commit 8917d60

Please sign in to comment.