Skip to content

Commit

Permalink
Merge pull request #54 from marten-seemann/fix-tests
Browse files Browse the repository at this point in the history
reduce the number of streams in the stress tests, fix error handling
  • Loading branch information
willscott committed Dec 18, 2020
2 parents 548b202 + b5e5775 commit 1587532
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions multistream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,29 @@ func (s *rwcStrict) Close() error {
func newPipe(t *testing.T) (io.ReadWriteCloser, io.ReadWriteCloser) {
ln, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Error(err)
t.Fatal(err)
}
cchan := make(chan net.Conn)
errChan := make(chan error, 1)
go func() {
c, err := ln.Accept()
if err != nil {
t.Error(err)
errChan <- err
return
}
cchan <- c
}()
c, err := net.Dial("tcp", ln.Addr().String())
if err != nil {
t.Error(err)
t.Fatal(err)
}
select {
case err := <-errChan:
t.Fatal(err)
return nil, nil
case rwc := <-cchan:
return newRwcStrict(t, rwc), newRwcStrict(t, c)
}
return newRwcStrict(t, <-cchan), newRwcStrict(t, c)
}

func TestProtocolNegotiation(t *testing.T) {
Expand Down Expand Up @@ -142,7 +150,7 @@ func TestProtocolNegotiationLazy(t *testing.T) {
}

func TestNegLazyStressRead(t *testing.T) {
count := 1000
const count = 100

mux := NewMultistreamMuxer()
mux.AddHandler("/a", nil)
Expand Down Expand Up @@ -195,7 +203,7 @@ func TestNegLazyStressRead(t *testing.T) {
}

func TestNegLazyStressWrite(t *testing.T) {
count := 1000
const count = 100

mux := NewMultistreamMuxer()
mux.AddHandler("/a", nil)
Expand Down

0 comments on commit 1587532

Please sign in to comment.