From 63390786eda009005dcdcaaa2eddd465f59fc85c Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 12 Jul 2016 13:27:12 +0200 Subject: [PATCH] test case for read timeout --- transport/internet/kcp/connection_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 transport/internet/kcp/connection_test.go diff --git a/transport/internet/kcp/connection_test.go b/transport/internet/kcp/connection_test.go new file mode 100644 index 00000000..36643f72 --- /dev/null +++ b/transport/internet/kcp/connection_test.go @@ -0,0 +1,21 @@ +package kcp_test + +import ( + "testing" + "time" + + "github.com/v2ray/v2ray-core/testing/assert" + . "github.com/v2ray/v2ray-core/transport/internet/kcp" +) + +func TestConnectionReadTimeout(t *testing.T) { + assert := assert.On(t) + + conn := NewConnection(1, nil, nil, nil, NewSimpleAuthenticator()) + conn.SetReadDeadline(time.Now().Add(time.Second)) + + b := make([]byte, 1024) + nBytes, err := conn.Read(b) + assert.Int(nBytes).Equals(0) + assert.Error(err).IsNotNil() +}