github.com/eagleql/xray-core@v1.4.4/transport/internet/dialer_test.go (about) 1 package internet_test 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/google/go-cmp/cmp" 8 9 "github.com/eagleql/xray-core/common" 10 "github.com/eagleql/xray-core/common/net" 11 "github.com/eagleql/xray-core/testing/servers/tcp" 12 . "github.com/eagleql/xray-core/transport/internet" 13 ) 14 15 func TestDialWithLocalAddr(t *testing.T) { 16 server := &tcp.Server{} 17 dest, err := server.Start() 18 common.Must(err) 19 defer server.Close() 20 21 conn, err := DialSystem(context.Background(), net.TCPDestination(net.LocalHostIP, dest.Port), nil) 22 common.Must(err) 23 if r := cmp.Diff(conn.RemoteAddr().String(), "127.0.0.1:"+dest.Port.String()); r != "" { 24 t.Error(r) 25 } 26 conn.Close() 27 }