From 01ed6b174171dada84ec1287424f31cbeb3ca40f Mon Sep 17 00:00:00 2001
From: iamqizhao <toqizhao@gmail.com>
Date: Tue, 19 Jul 2016 11:54:35 -0700
Subject: [PATCH] improve the test

---
 transport/transport_test.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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