mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
refactor test
This commit is contained in:
parent
661c0fc237
commit
087a91c46c
@ -61,31 +61,43 @@ func readFrom(conn net.Conn, timeout time.Duration, length int) []byte {
|
||||
return b[:n]
|
||||
}
|
||||
|
||||
func InitializeServerConfig(config *core.Config) error {
|
||||
func InitializeServerConfigs(configs ...*core.Config) ([]*exec.Cmd, error) {
|
||||
servers := make([]*exec.Cmd, 0, 10)
|
||||
|
||||
for _, config := range configs {
|
||||
server, err := InitializeServerConfig(config)
|
||||
if err != nil {
|
||||
CloseAllServers(servers)
|
||||
return nil, err
|
||||
}
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
time.Sleep(time.Second * 2)
|
||||
|
||||
return servers, nil
|
||||
}
|
||||
|
||||
func InitializeServerConfig(config *core.Config) (*exec.Cmd, error) {
|
||||
err := BuildV2Ray()
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
configBytes, err := proto.Marshal(config)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
proc := RunV2RayProtobuf(configBytes)
|
||||
|
||||
if err := proc.Start(); err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
time.Sleep(time.Second)
|
||||
|
||||
runningServers = append(runningServers, proc)
|
||||
|
||||
return nil
|
||||
return proc, nil
|
||||
}
|
||||
|
||||
var (
|
||||
runningServers = make([]*exec.Cmd, 0, 10)
|
||||
testBinaryPath string
|
||||
testBinaryPathGen sync.Once
|
||||
)
|
||||
@ -114,14 +126,13 @@ func GetSourcePath() string {
|
||||
return filepath.Join("v2ray.com", "core", "main")
|
||||
}
|
||||
|
||||
func CloseAllServers() {
|
||||
func CloseAllServers(servers []*exec.Cmd) {
|
||||
log.Trace(errors.New("Closing all servers."))
|
||||
for _, server := range runningServers {
|
||||
for _, server := range servers {
|
||||
server.Process.Signal(os.Interrupt)
|
||||
}
|
||||
for _, server := range runningServers {
|
||||
for _, server := range servers {
|
||||
server.Process.Wait()
|
||||
}
|
||||
runningServers = make([]*exec.Cmd, 0, 10)
|
||||
log.Trace(errors.New("All server closed."))
|
||||
}
|
||||
|
@ -80,7 +80,8 @@ func TestResolveIP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
{
|
||||
noAuthDialer, err := xproxy.SOCKS5("tcp", v2net.TCPDestination(v2net.LocalHostIP, serverPort).NetAddr(), nil, xproxy.Direct)
|
||||
@ -100,5 +101,5 @@ func TestResolveIP(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ func TestDokodemoTCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
for port := clientPort; port <= clientPort+clientPortRange; port++ {
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
@ -118,7 +118,7 @@ func TestDokodemoTCP(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestDokodemoUDP(t *testing.T) {
|
||||
@ -197,8 +197,8 @@ func TestDokodemoUDP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
for port := clientPort; port <= clientPort+clientPortRange; port++ {
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
@ -219,5 +219,5 @@ func TestDokodemoUDP(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package scenarios
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"io/ioutil"
|
||||
|
||||
xproxy "golang.org/x/net/proxy"
|
||||
"v2ray.com/core"
|
||||
"v2ray.com/core/app/log"
|
||||
@ -67,7 +66,8 @@ func TestPassiveConnection(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -99,7 +99,7 @@ func TestPassiveConnection(t *testing.T) {
|
||||
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestProxy(t *testing.T) {
|
||||
@ -227,9 +227,8 @@ func TestProxy(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(proxyConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, proxyConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -248,7 +247,7 @@ func TestProxy(t *testing.T) {
|
||||
assert.Bytes(response[:nBytes]).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestProxyOverKCP(t *testing.T) {
|
||||
@ -387,9 +386,8 @@ func TestProxyOverKCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(proxyConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, proxyConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -408,7 +406,7 @@ func TestProxyOverKCP(t *testing.T) {
|
||||
assert.Bytes(response[:nBytes]).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestBlackhole(t *testing.T) {
|
||||
@ -481,7 +479,8 @@ func TestBlackhole(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -505,7 +504,7 @@ func TestBlackhole(t *testing.T) {
|
||||
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestForward(t *testing.T) {
|
||||
@ -550,7 +549,8 @@ func TestForward(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
{
|
||||
noAuthDialer, err := xproxy.SOCKS5("tcp", v2net.TCPDestination(v2net.LocalHostIP, serverPort).NetAddr(), nil, xproxy.Direct)
|
||||
@ -570,7 +570,7 @@ func TestForward(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestUDPConnection(t *testing.T) {
|
||||
@ -607,7 +607,8 @@ func TestUDPConnection(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
{
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
@ -652,7 +653,7 @@ func TestUDPConnection(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestDomainSniffing(t *testing.T) {
|
||||
@ -724,7 +725,8 @@ func TestDomainSniffing(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -744,5 +746,5 @@ func TestDomainSniffing(t *testing.T) {
|
||||
assert.Error(resp.Write(ioutil.Discard)).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ func TestHttpConformance(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -69,5 +70,5 @@ func TestHttpConformance(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ func TestShadowsocksAES256TCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -136,7 +136,7 @@ func TestShadowsocksAES256TCP(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestShadowsocksAES128UDP(t *testing.T) {
|
||||
@ -227,8 +227,8 @@ func TestShadowsocksAES128UDP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -255,7 +255,7 @@ func TestShadowsocksAES128UDP(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestShadowsocksChacha20TCP(t *testing.T) {
|
||||
@ -345,8 +345,8 @@ func TestShadowsocksChacha20TCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -373,5 +373,5 @@ func TestShadowsocksChacha20TCP(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -93,8 +93,8 @@ func TestSocksBridgeTCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -113,7 +113,7 @@ func TestSocksBridgeTCP(t *testing.T) {
|
||||
assert.Bytes(response[:nBytes]).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestSocksBridageUDP(t *testing.T) {
|
||||
@ -190,8 +190,8 @@ func TestSocksBridageUDP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -210,7 +210,7 @@ func TestSocksBridageUDP(t *testing.T) {
|
||||
assert.Bytes(response[:nBytes]).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestSocksConformance(t *testing.T) {
|
||||
@ -263,7 +263,8 @@ func TestSocksConformance(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
{
|
||||
noAuthDialer, err := xproxy.SOCKS5("tcp", v2net.TCPDestination(v2net.LocalHostIP, noAuthPort).NetAddr(), nil, xproxy.Direct)
|
||||
@ -335,5 +336,5 @@ func TestSocksConformance(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -118,8 +118,8 @@ func TestSimpleTLSConnection(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -136,7 +136,7 @@ func TestSimpleTLSConnection(t *testing.T) {
|
||||
assert.Bytes(response).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestTLSOverKCP(t *testing.T) {
|
||||
@ -150,7 +150,7 @@ func TestTLSOverKCP(t *testing.T) {
|
||||
defer tcpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
serverPort := pickPort()
|
||||
serverPort := pickUDPPort()
|
||||
serverConfig := &core.Config{
|
||||
Inbound: []*proxyman.InboundHandlerConfig{
|
||||
{
|
||||
@ -234,8 +234,8 @@ func TestTLSOverKCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -252,7 +252,7 @@ func TestTLSOverKCP(t *testing.T) {
|
||||
assert.Bytes(response).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestTLSOverWebSocket(t *testing.T) {
|
||||
@ -356,8 +356,8 @@ func TestTLSOverWebSocket(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -375,5 +375,5 @@ func TestTLSOverWebSocket(t *testing.T) {
|
||||
assert.Bytes(response).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -120,8 +120,8 @@ func TestHttpConnectionHeader(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
@ -138,5 +138,5 @@ func TestHttpConnectionHeader(t *testing.T) {
|
||||
assert.Bytes(response).Equals(xor([]byte(payload)))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
@ -135,8 +135,8 @@ func TestVMessDynamicPort(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
@ -157,7 +157,7 @@ func TestVMessDynamicPort(t *testing.T) {
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessGCM(t *testing.T) {
|
||||
@ -252,8 +252,8 @@ func TestVMessGCM(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -280,7 +280,7 @@ func TestVMessGCM(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessGCMUDP(t *testing.T) {
|
||||
@ -375,8 +375,8 @@ func TestVMessGCMUDP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -413,7 +413,7 @@ func TestVMessGCMUDP(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessChacha20(t *testing.T) {
|
||||
@ -508,8 +508,8 @@ func TestVMessChacha20(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -536,7 +536,7 @@ func TestVMessChacha20(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessNone(t *testing.T) {
|
||||
@ -631,8 +631,8 @@ func TestVMessNone(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -659,7 +659,7 @@ func TestVMessNone(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessKCP(t *testing.T) {
|
||||
@ -673,7 +673,7 @@ func TestVMessKCP(t *testing.T) {
|
||||
defer tcpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
serverPort := pickPort()
|
||||
serverPort := pickUDPPort()
|
||||
serverConfig := &core.Config{
|
||||
Inbound: []*proxyman.InboundHandlerConfig{
|
||||
{
|
||||
@ -762,8 +762,8 @@ func TestVMessKCP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
for i := 0; i < 10; i++ {
|
||||
@ -790,7 +790,7 @@ func TestVMessKCP(t *testing.T) {
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessIPv6(t *testing.T) {
|
||||
@ -887,8 +887,8 @@ func TestVMessIPv6(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: v2net.LocalHostIPv6.IP(),
|
||||
@ -907,7 +907,7 @@ func TestVMessIPv6(t *testing.T) {
|
||||
assert.Bytes(response).Equals(xor(payload))
|
||||
assert.Error(conn.Close()).IsNil()
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessGCMMux(t *testing.T) {
|
||||
@ -1008,8 +1008,8 @@ func TestVMessGCMMux(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
for range "abcd" {
|
||||
var wg sync.WaitGroup
|
||||
@ -1042,7 +1042,7 @@ func TestVMessGCMMux(t *testing.T) {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
||||
func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
@ -1164,8 +1164,8 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
assert.Error(InitializeServerConfig(serverConfig)).IsNil()
|
||||
assert.Error(InitializeServerConfig(clientConfig)).IsNil()
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
for range "abcd" {
|
||||
var wg sync.WaitGroup
|
||||
@ -1232,5 +1232,5 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
CloseAllServers()
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user