Explorar o código

test case for read timeout

v2ray %!s(int64=9) %!d(string=hai) anos
pai
achega
63390786ed
Modificáronse 1 ficheiros con 21 adicións e 0 borrados
  1. 21 0
      transport/internet/kcp/connection_test.go

+ 21 - 0
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()
+}