mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-09-06 03:54:22 -04:00
34 lines
652 B
Go
34 lines
652 B
Go
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()
|
|
}
|