diff --git a/transport/transport_test.go b/transport/transport_test.go index ce015da2..050b4649 100644 --- a/transport/transport_test.go +++ b/transport/transport_test.go @@ -433,6 +433,7 @@ func TestMaxStreams(t *testing.T) { } done := make(chan struct{}) ch := make(chan int) + ready := make(chan struct{}) go func() { for { select { @@ -441,6 +442,8 @@ func TestMaxStreams(t *testing.T) { case <-time.After(5 * time.Second): close(done) return + case <-ready: + return } } }() @@ -467,6 +470,7 @@ func TestMaxStreams(t *testing.T) { } cc.mu.Unlock() } + close(ready) // Close the pending stream so that the streams quota becomes available for the next new stream. ct.CloseStream(s, nil) select { @@ -690,7 +694,8 @@ func TestClientWithMisbehavedServer(t *testing.T) { Host: "localhost", Method: "foo.MaxFrame", } - for i := 0; i < int(initialConnWindowSize/initialWindowSize+10); i++ { + // Make the server flood the traffic to violate flow control window size of the connection. + for { s, err := ct.NewStream(context.Background(), callHdr) if err != nil { break