mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 10:08:15 -05:00
KCP:Some Tests
This commit is contained in:
parent
0f368f8139
commit
18841209ee
31
transport/hub/kcp_test.go
Normal file
31
transport/hub/kcp_test.go
Normal file
@ -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()
|
||||
}
|
Loading…
Reference in New Issue
Block a user