mirror of https://github.com/v2ray/v2ray-core
update test case
parent
991b2703dc
commit
c32f1a0152
|
@ -49,16 +49,25 @@ func TestConnectionReadWrite(t *testing.T) {
|
||||||
totalWritten := 1024 * 1024
|
totalWritten := 1024 * 1024
|
||||||
clientSend := make([]byte, totalWritten)
|
clientSend := make([]byte, totalWritten)
|
||||||
rand.Read(clientSend)
|
rand.Read(clientSend)
|
||||||
nBytes, err := connClient.Write(clientSend)
|
go func() {
|
||||||
assert.Int(nBytes).Equals(totalWritten)
|
nBytes, err := connClient.Write(clientSend)
|
||||||
assert.Error(err).IsNil()
|
assert.Int(nBytes).Equals(totalWritten)
|
||||||
|
assert.Error(err).IsNil()
|
||||||
|
}()
|
||||||
|
|
||||||
serverReceived := make([]byte, totalWritten)
|
serverReceived := make([]byte, totalWritten)
|
||||||
totalRead := 0
|
totalRead := 0
|
||||||
for totalRead < totalWritten {
|
for totalRead < totalWritten {
|
||||||
nBytes, err = connServer.Read(serverReceived[totalRead:])
|
nBytes, err := connServer.Read(serverReceived[totalRead:])
|
||||||
assert.Error(err).IsNil()
|
assert.Error(err).IsNil()
|
||||||
totalRead += nBytes
|
totalRead += nBytes
|
||||||
}
|
}
|
||||||
assert.Bytes(serverReceived).Equals(clientSend)
|
assert.Bytes(serverReceived).Equals(clientSend)
|
||||||
|
|
||||||
|
connClient.Close()
|
||||||
|
connServer.Close()
|
||||||
|
|
||||||
|
for connClient.State() != StateTerminated || connServer.State() != StateTerminated {
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue