From 18841209ee31a6b1fb9acb731bbfaf8963b95894 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Mon, 13 Jun 2016 15:57:49 +0800 Subject: [PATCH] KCP:Some Tests --- transport/hub/kcp_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 transport/hub/kcp_test.go diff --git a/transport/hub/kcp_test.go b/transport/hub/kcp_test.go new file mode 100644 index 00000000..30feb80b --- /dev/null +++ b/transport/hub/kcp_test.go @@ -0,0 +1,31 @@ +package hub_test + +import "testing" + +import ( + v2net "github.com/v2ray/v2ray-core/common/net" + "github.com/v2ray/v2ray-core/testing/assert" + "github.com/v2ray/v2ray-core/transport" + "github.com/v2ray/v2ray-core/transport/hub" + "github.com/v2ray/v2ray-core/transport/hub/kcpv" +) + +func Test_Pair(t *testing.T) { + assert := assert.On(t) + transport.KcpConfig = &kcpv.Config{} + transport.KcpConfig.Mode = "fast2" + transport.KcpConfig.Key = "key" + transport.KcpConfig.AdvancedConfigs = kcpv.DefaultAdvancedConfigs + lst, _ := hub.ListenKCP(v2net.ParseAddress("127.0.0.1"), 17777) + go func() { + connx, err2 := lst.Accept() + assert.Error(err2).IsNil() + connx.Close() + }() + conn, _ := hub.DialKCP(v2net.TCPDestination(v2net.ParseAddress("127.0.0.1"), 17777)) + conn.LocalAddr() + conn.RemoteAddr() + conn.ApplyConf() + conn.Write([]byte("x")) + conn.Close() +}