v2ray-core/transport/internet/dialer_test.go

26 lines
609 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 (
2017-04-08 22:54:07 +00:00
"context"
2016-01-21 12:18:37 +00:00
"testing"
2017-01-13 23:27:45 +00:00
"v2ray.com/core/common/net"
2016-08-20 18:55:45 +00:00
"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()
2017-02-23 22:48:47 +00:00
conn, err := DialSystem(context.Background(), net.LocalHostIP, net.TCPDestination(net.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()
}