From 90504fc07731a8cea8329912c78c6caf1a62bea4 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 22 Nov 2016 00:20:06 +0100 Subject: [PATCH] better error handling --- testing/scenarios/shadowsocks_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testing/scenarios/shadowsocks_test.go b/testing/scenarios/shadowsocks_test.go index 2d818af0..0115e856 100644 --- a/testing/scenarios/shadowsocks_test.go +++ b/testing/scenarios/shadowsocks_test.go @@ -1,9 +1,9 @@ package scenarios import ( + "fmt" "net" "testing" - "v2ray.com/core/common/alloc" v2net "v2ray.com/core/common/net" "v2ray.com/core/testing/assert" @@ -44,16 +44,21 @@ func TestShadowsocksTCP(t *testing.T) { response := alloc.NewBuffer().Clear() finished := false + expectedResponse := "Processed: " + payload for { _, err := response.FillFrom(conn) assert.Error(err).IsNil() if err != nil { break } - if response.String() == "Processed: "+payload { + if response.String() == expectedResponse { finished = true break } + if response.Len() > len(expectedResponse) { + fmt.Printf("Unexpected response: %s\n", response.String()) + break + } } assert.Bool(finished).IsTrue()