v2ray-core/transport/internet/dialer_test.go

25 lines
588 B
Go
Raw Normal View History

2016-06-14 20:54:08 +00:00
package internet_test
2016-01-21 12:18:37 +00:00
import (
"testing"
2016-08-20 18:55:45 +00:00
v2net "v2ray.com/core/common/net"
"v2ray.com/core/testing/assert"
"v2ray.com/core/testing/servers/tcp"
. "v2ray.com/core/transport/internet"
2016-01-21 12:18:37 +00:00
)
2016-06-03 22:38:22 +00:00
func TestDialWithLocalAddr(t *testing.T) {
assert := assert.On(t)
2016-08-15 20:12:11 +00:00
server := &tcp.Server{}
2016-06-03 22:38:22 +00:00
dest, err := server.Start()
assert.Error(err).IsNil()
defer server.Close()
2016-09-20 09:53:05 +00:00
conn, err := DialToDest(v2net.LocalHostIP, v2net.TCPDestination(v2net.LocalHostIP, dest.Port))
2016-01-21 12:27:08 +00:00
assert.Error(err).IsNil()
2016-09-20 09:53:05 +00:00
assert.String(conn.RemoteAddr().String()).Equals("127.0.0.1:" + dest.Port.String())
2016-01-21 12:18:37 +00:00
conn.Close()
}