mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-05 00:47:51 -05:00
more complicated mux test
This commit is contained in:
parent
bf0a4c428e
commit
a49816ae46
@ -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
|
for range "abcd" {
|
||||||
wg.Add(100)
|
var wg sync.WaitGroup
|
||||||
for i := 0; i < 100; i++ {
|
const nConnection = 100
|
||||||
go func() {
|
wg.Add(nConnection)
|
||||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
for i := 0; i < nConnection; i++ {
|
||||||
IP: []byte{127, 0, 0, 1},
|
go func() {
|
||||||
Port: int(clientPort),
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||||
})
|
IP: []byte{127, 0, 0, 1},
|
||||||
assert.Error(err).IsNil()
|
Port: int(clientPort),
|
||||||
|
})
|
||||||
|
assert.Error(err).IsNil()
|
||||||
|
|
||||||
payload := make([]byte, 10240)
|
payload := make([]byte, 10240)
|
||||||
rand.Read(payload)
|
rand.Read(payload)
|
||||||
|
|
||||||
nBytes, err := conn.Write([]byte(payload))
|
nBytes, err := conn.Write([]byte(payload))
|
||||||
assert.Error(err).IsNil()
|
assert.Error(err).IsNil()
|
||||||
assert.Int(nBytes).Equals(len(payload))
|
assert.Int(nBytes).Equals(len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*10, 10240)
|
response := readFrom(conn, time.Second*10, 10240)
|
||||||
assert.Bytes(response).Equals(xor([]byte(payload)))
|
assert.Bytes(response).Equals(xor([]byte(payload)))
|
||||||
assert.Error(conn.Close()).IsNil()
|
assert.Error(conn.Close()).IsNil()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
}
|
}
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
CloseAllServers()
|
CloseAllServers()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user