update test case

pull/215/head
v2ray 2016-07-14 21:31:04 +02:00
parent 991b2703dc
commit c32f1a0152
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 13 additions and 4 deletions

View File

@ -49,16 +49,25 @@ func TestConnectionReadWrite(t *testing.T) {
totalWritten := 1024 * 1024
clientSend := make([]byte, totalWritten)
rand.Read(clientSend)
nBytes, err := connClient.Write(clientSend)
assert.Int(nBytes).Equals(totalWritten)
assert.Error(err).IsNil()
go func() {
nBytes, err := connClient.Write(clientSend)
assert.Int(nBytes).Equals(totalWritten)
assert.Error(err).IsNil()
}()
serverReceived := make([]byte, totalWritten)
totalRead := 0
for totalRead < totalWritten {
nBytes, err = connServer.Read(serverReceived[totalRead:])
nBytes, err := connServer.Read(serverReceived[totalRead:])
assert.Error(err).IsNil()
totalRead += nBytes
}
assert.Bytes(serverReceived).Equals(clientSend)
connClient.Close()
connServer.Close()
for connClient.State() != StateTerminated || connServer.State() != StateTerminated {
time.Sleep(time.Second)
}
}