1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-06 09:26:59 -05:00

concurrent connection in h2

This commit is contained in:
Darien Raymond 2018-03-01 21:42:42 +01:00
parent 20be8aab61
commit 2e7944a9eb
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -2,6 +2,7 @@ package scenarios
import ( import (
"crypto/rand" "crypto/rand"
"sync"
"testing" "testing"
"time" "time"
@ -495,6 +496,12 @@ func TestHTTP2(t *testing.T) {
servers, err := InitializeServerConfigs(serverConfig, clientConfig) servers, err := InitializeServerConfigs(serverConfig, clientConfig)
assert(err, IsNil) assert(err, IsNil)
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func() {
defer wg.Done()
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{ conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
IP: []byte{127, 0, 0, 1}, IP: []byte{127, 0, 0, 1},
Port: int(clientPort), Port: int(clientPort),
@ -510,6 +517,9 @@ func TestHTTP2(t *testing.T) {
response := readFrom(conn, time.Second*20, len(payload)) response := readFrom(conn, time.Second*20, len(payload))
assert(response, Equals, xor([]byte(payload))) assert(response, Equals, xor([]byte(payload)))
assert(conn.Close(), IsNil) assert(conn.Close(), IsNil)
}()
}
wg.Wait()
CloseAllServers(servers) CloseAllServers(servers)
} }