1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

Explictly wait for server ready

This commit is contained in:
V2Ray 2015-09-24 18:08:55 +02:00
parent 9e4902d17a
commit d77fdbd719

View File

@ -3,6 +3,7 @@ package freedom
import (
"io/ioutil"
"net"
"sync"
"testing"
"golang.org/x/net/proxy"
@ -20,6 +21,9 @@ func TestSocksTcpConnect(t *testing.T) {
data2Send := "Data to be sent to remote"
data2Return := "Data to be returned to local"
var serverReady sync.Mutex
serverReady.Lock()
go func() {
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
IP: []byte{0, 0, 0, 0},
@ -27,6 +31,8 @@ func TestSocksTcpConnect(t *testing.T) {
Zone: "",
})
assert.Error(err).IsNil()
serverReady.Unlock()
conn, err := listener.Accept()
assert.Error(err).IsNil()
@ -65,6 +71,8 @@ func TestSocksTcpConnect(t *testing.T) {
socks5Client, err := proxy.SOCKS5("tcp", "127.0.0.1:38724", nil, proxy.Direct)
assert.Error(err).IsNil()
serverReady.Lock()
targetServer := "127.0.0.1:48274"
conn, err := socks5Client.Dial("tcp", targetServer)
assert.Error(err).IsNil()