test case for read timeout

pull/215/head
v2ray 2016-07-12 13:27:12 +02:00
parent a88a120938
commit 63390786ed
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 21 additions and 0 deletions

View File

@ -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()
}