1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-16 09:26:21 -05:00
v2fly/transport/internet/dialer_test.go

28 lines
664 B
Go
Raw Normal View History

2016-06-14 16:54:08 -04:00
package internet_test
2016-01-21 07:18:37 -05:00
import (
2017-04-08 18:54:07 -04:00
"context"
2016-01-21 07:18:37 -05:00
"testing"
2019-01-08 17:27:02 -05:00
"github.com/google/go-cmp/cmp"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/net"
"github.com/v2fly/v2ray-core/v5/testing/servers/tcp"
. "github.com/v2fly/v2ray-core/v5/transport/internet"
2016-01-21 07:18:37 -05:00
)
2016-06-03 18:38:22 -04:00
func TestDialWithLocalAddr(t *testing.T) {
2016-08-15 16:12:11 -04:00
server := &tcp.Server{}
2016-06-03 18:38:22 -04:00
dest, err := server.Start()
2019-01-08 17:27:02 -05:00
common.Must(err)
2016-06-03 18:38:22 -04:00
defer server.Close()
conn, err := DialSystem(context.Background(), net.TCPDestination(net.LocalHostIP, dest.Port), nil)
2019-01-08 17:27:02 -05:00
common.Must(err)
if r := cmp.Diff(conn.RemoteAddr().String(), "127.0.0.1:"+dest.Port.String()); r != "" {
t.Error(r)
}
2016-01-21 07:18:37 -05:00
conn.Close()
}