better error handling

pull/314/head
Darien Raymond 8 years ago
parent 85da0dae28
commit 90504fc077
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -1,9 +1,9 @@
package scenarios package scenarios
import ( import (
"fmt"
"net" "net"
"testing" "testing"
"v2ray.com/core/common/alloc" "v2ray.com/core/common/alloc"
v2net "v2ray.com/core/common/net" v2net "v2ray.com/core/common/net"
"v2ray.com/core/testing/assert" "v2ray.com/core/testing/assert"
@ -44,16 +44,21 @@ func TestShadowsocksTCP(t *testing.T) {
response := alloc.NewBuffer().Clear() response := alloc.NewBuffer().Clear()
finished := false finished := false
expectedResponse := "Processed: " + payload
for { for {
_, err := response.FillFrom(conn) _, err := response.FillFrom(conn)
assert.Error(err).IsNil() assert.Error(err).IsNil()
if err != nil { if err != nil {
break break
} }
if response.String() == "Processed: "+payload { if response.String() == expectedResponse {
finished = true finished = true
break break
} }
if response.Len() > len(expectedResponse) {
fmt.Printf("Unexpected response: %s\n", response.String())
break
}
} }
assert.Bool(finished).IsTrue() assert.Bool(finished).IsTrue()

Loading…
Cancel
Save