浏览代码

more complicated mux test

Darien Raymond 8 年之前
父节点
当前提交
a49816ae46
共有 1 个文件被更改,包括 26 次插入23 次删除
  1. 26 23
      testing/scenarios/vmess_test.go

+ 26 - 23
testing/scenarios/vmess_test.go

@@ -876,30 +876,33 @@ func TestVMessGCMMux(t *testing.T) {
 	assert.Error(InitializeServerConfig(serverConfig)).IsNil()
 	assert.Error(InitializeServerConfig(serverConfig)).IsNil()
 	assert.Error(InitializeServerConfig(clientConfig)).IsNil()
 	assert.Error(InitializeServerConfig(clientConfig)).IsNil()
 
 
-	var wg sync.WaitGroup
-	wg.Add(100)
-	for i := 0; i < 100; i++ {
-		go func() {
-			conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
-				IP:   []byte{127, 0, 0, 1},
-				Port: int(clientPort),
-			})
-			assert.Error(err).IsNil()
-
-			payload := make([]byte, 10240)
-			rand.Read(payload)
-
-			nBytes, err := conn.Write([]byte(payload))
-			assert.Error(err).IsNil()
-			assert.Int(nBytes).Equals(len(payload))
-
-			response := readFrom(conn, time.Second*10, 10240)
-			assert.Bytes(response).Equals(xor([]byte(payload)))
-			assert.Error(conn.Close()).IsNil()
-			wg.Done()
-		}()
+	for range "abcd" {
+		var wg sync.WaitGroup
+		const nConnection = 100
+		wg.Add(nConnection)
+		for i := 0; i < nConnection; i++ {
+			go func() {
+				conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
+					IP:   []byte{127, 0, 0, 1},
+					Port: int(clientPort),
+				})
+				assert.Error(err).IsNil()
+
+				payload := make([]byte, 10240)
+				rand.Read(payload)
+
+				nBytes, err := conn.Write([]byte(payload))
+				assert.Error(err).IsNil()
+				assert.Int(nBytes).Equals(len(payload))
+
+				response := readFrom(conn, time.Second*10, 10240)
+				assert.Bytes(response).Equals(xor([]byte(payload)))
+				assert.Error(conn.Close()).IsNil()
+				wg.Done()
+			}()
+		}
+		wg.Wait()
 	}
 	}
-	wg.Wait()
 
 
 	CloseAllServers()
 	CloseAllServers()
 }
 }