Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Commit

Permalink
test: make sure to wait for the stream sub-tests to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Feb 8, 2019
1 parent 22414bc commit 2a0231a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions test/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,35 @@ func SubtestStress(t *testing.T, ta, tb tpt.Transport, maddr ma.Multiaddr, peerA
c, err := tb.Dial(context.Background(), l.Multiaddr(), peerA)
checkErr(t, err)

var wg sync.WaitGroup

// serve the outgoing conn, because some muxers assume
// that we _always_ call serve. (this is an error?)
wg.Add(1)
go func() {
defer wg.Done()

debugLog(t, "serving connection")
for {
for i := 0; i < opt.streamNum; i++ {
str, err := c.AcceptStream()
if err != nil {
t.Error(err)
break
}
go echoStream(t, str)

wg.Add(1)
go func() {
defer wg.Done()
echoStream(t, str)
}()
}
s, err := c.AcceptStream()
if err == nil {
s.Reset()
t.Error("got too many streams")
}
}()

var wg sync.WaitGroup
for i := 0; i < opt.streamNum; i++ {
wg.Add(1)
go rateLimit(func() {
Expand Down

0 comments on commit 2a0231a

Please sign in to comment.