1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-23 10:37:09 -05:00
v2fly/transport/internet/kcp/connection_test.go
2022-01-02 15:16:23 +00:00

39 lines
799 B
Go

package kcp_test
import (
"io"
"testing"
"time"
"github.com/v2fly/v2ray-core/v5/common/buf"
. "github.com/v2fly/v2ray-core/v5/transport/internet/kcp"
)
type NoOpCloser int
func (NoOpCloser) Close() error {
return nil
}
func TestConnectionReadTimeout(t *testing.T) {
conn := NewConnection(ConnMetadata{Conversation: 1}, &KCPPacketWriter{
Writer: buf.DiscardBytes,
}, NoOpCloser(0), &Config{})
conn.SetReadDeadline(time.Now().Add(time.Second))
b := make([]byte, 1024)
nBytes, err := conn.Read(b)
if nBytes != 0 || err == nil {
t.Error("unexpected read: ", nBytes, err)
}
conn.Terminate()
}
func TestConnectionInterface(t *testing.T) {
_ = (io.Writer)(new(Connection))
_ = (io.Reader)(new(Connection))
_ = (buf.Reader)(new(Connection))
_ = (buf.Writer)(new(Connection))
}