1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-09 03:37:37 -05:00
v2fly/transport/dialer/dialer_test.go

29 lines
781 B
Go
Raw Normal View History

2016-01-21 07:18:37 -05:00
package dialer_test
import (
"testing"
v2net "github.com/v2ray/v2ray-core/common/net"
2016-01-21 07:27:08 -05:00
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
2016-01-21 07:18:37 -05:00
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
2016-01-21 07:27:08 -05:00
"github.com/v2ray/v2ray-core/testing/servers/tcp"
2016-01-21 07:18:37 -05:00
. "github.com/v2ray/v2ray-core/transport/dialer"
)
func TestDialDomain(t *testing.T) {
v2testing.Current(t)
2016-01-21 07:27:08 -05:00
server := &tcp.Server{
Port: v2nettesting.PickPort(),
}
dest, err := server.Start()
2016-01-21 07:18:37 -05:00
assert.Error(err).IsNil()
2016-01-21 16:45:44 -05:00
defer server.Close()
2016-01-21 07:27:08 -05:00
conn, err := Dial(v2net.TCPDestination(v2net.DomainAddress("local.v2ray.com"), dest.Port()))
assert.Error(err).IsNil()
assert.StringLiteral(conn.RemoteAddr().String()).Equals("127.0.0.1:" + dest.Port().String())
2016-01-21 07:18:37 -05:00
conn.Close()
}