You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/transport/internet/kcp/connection_test.go

34 lines
652 B

package kcp_test
import (
"testing"
"time"
"v2ray.com/core/testing/assert"
. "v2ray.com/core/transport/internet/kcp"
)
type NoOpWriteCloser struct{}
func (this *NoOpWriteCloser) Write(b []byte) (int, error) {
return len(b), nil
}
func (this *NoOpWriteCloser) Close() error {
return nil
}
func TestConnectionReadTimeout(t *testing.T) {
assert := assert.On(t)
conn := NewConnection(1, &NoOpWriteCloser{}, nil, nil, NewSimpleAuthenticator(), &Config{})
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()
conn.Terminate()
}