mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
https://github.com/XTLS/Xray-core/issues/4846#issuecomment-4150329444 https://github.com/XTLS/Xray-core/pull/5872#issuecomment-4184774915 https://github.com/XTLS/Xray-core/pull/5890#issuecomment-4240052251
44 lines
917 B
Go
44 lines
917 B
Go
package kcp_test
|
|
|
|
import (
|
|
"io"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/xtls/xray-core/common/buf"
|
|
. "github.com/xtls/xray-core/transport/internet/kcp"
|
|
)
|
|
|
|
type NoOpCloser int
|
|
|
|
func (NoOpCloser) Close() error {
|
|
return nil
|
|
}
|
|
|
|
func TestConnectionReadTimeout(t *testing.T) {
|
|
conn := NewConnection(ConnMetadata{Conversation: 1}, buf.DiscardBytes, NoOpCloser(0), &Config{
|
|
Mtu: 1350,
|
|
Tti: 50,
|
|
UplinkCapacity: 5,
|
|
DownlinkCapacity: 20,
|
|
CwndMultiplier: 20,
|
|
MaxSendingWindow: 2 * 1024 * 1024,
|
|
})
|
|
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))
|
|
}
|