Skip to content

Commit

Permalink
add test for read after close
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed May 23, 2019
1 parent 8917d60 commit 50a8f1b
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 @@ -455,6 +455,32 @@ func TestDeadline(t *testing.T) {
}
}

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
Expand Down

0 comments on commit 50a8f1b

Please sign in to comment.