move net/testing/assert into assert

pull/168/head
v2ray 2016-05-24 15:29:08 +02:00
parent bbdc692a93
commit 3582b9d869
18 changed files with 43 additions and 61 deletions

View File

@ -8,7 +8,6 @@ import (
. "github.com/v2ray/v2ray-core/app/dns" . "github.com/v2ray/v2ray-core/app/dns"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
) )
@ -24,7 +23,7 @@ func TestConfigParsing(t *testing.T) {
err := json.Unmarshal([]byte(rawJson), config) err := json.Unmarshal([]byte(rawJson), config)
assert.Error(err).IsNil() assert.Error(err).IsNil()
assert.Int(len(config.NameServers)).Equals(1) assert.Int(len(config.NameServers)).Equals(1)
netassert.Destination(config.NameServers[0]).IsUDP() assert.Destination(config.NameServers[0]).IsUDP()
netassert.Address(config.NameServers[0].Address()).Equals(v2net.IPAddress([]byte{8, 8, 8, 8})) assert.Address(config.NameServers[0].Address()).Equals(v2net.IPAddress([]byte{8, 8, 8, 8}))
netassert.Port(config.NameServers[0].Port()).Equals(v2net.Port(53)) assert.Port(config.NameServers[0].Port()).Equals(v2net.Port(53))
} }

View File

@ -10,7 +10,6 @@ import (
. "github.com/v2ray/v2ray-core/app/dns" . "github.com/v2ray/v2ray-core/app/dns"
"github.com/v2ray/v2ray-core/app/proxyman" "github.com/v2ray/v2ray-core/app/proxyman"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
"github.com/v2ray/v2ray-core/proxy/freedom" "github.com/v2ray/v2ray-core/proxy/freedom"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
@ -37,5 +36,5 @@ func TestDnsAdd(t *testing.T) {
ips := server.Get(domain) ips := server.Get(domain)
assert.Int(len(ips)).Equals(1) assert.Int(len(ips)).Equals(1)
netassert.IP(ips[0].To4()).Equals(net.IP([]byte{127, 0, 0, 1})) assert.IP(ips[0].To4()).Equals(net.IP([]byte{127, 0, 0, 1}))
} }

View File

@ -5,7 +5,6 @@ import (
"testing" "testing"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
) )
@ -16,9 +15,9 @@ func TestIPv4Address(t *testing.T) {
ip := []byte{byte(1), byte(2), byte(3), byte(4)} ip := []byte{byte(1), byte(2), byte(3), byte(4)}
addr := v2net.IPAddress(ip) addr := v2net.IPAddress(ip)
v2netassert.Address(addr).IsIPv4() assert.Address(addr).IsIPv4()
v2netassert.Address(addr).IsNotIPv6() assert.Address(addr).IsNotIPv6()
v2netassert.Address(addr).IsNotDomain() assert.Address(addr).IsNotDomain()
assert.Bytes(addr.IP()).Equals(ip) assert.Bytes(addr.IP()).Equals(ip)
assert.String(addr).Equals("1.2.3.4") assert.String(addr).Equals("1.2.3.4")
} }
@ -34,9 +33,9 @@ func TestIPv6Address(t *testing.T) {
} }
addr := v2net.IPAddress(ip) addr := v2net.IPAddress(ip)
v2netassert.Address(addr).IsIPv6() assert.Address(addr).IsIPv6()
v2netassert.Address(addr).IsNotIPv4() assert.Address(addr).IsNotIPv4()
v2netassert.Address(addr).IsNotDomain() assert.Address(addr).IsNotDomain()
assert.Bytes(addr.IP()).Equals(ip) assert.Bytes(addr.IP()).Equals(ip)
assert.String(addr).Equals("[102:304:102:304:102:304:102:304]") assert.String(addr).Equals("[102:304:102:304:102:304:102:304]")
} }
@ -59,9 +58,9 @@ func TestDomainAddress(t *testing.T) {
domain := "v2ray.com" domain := "v2ray.com"
addr := v2net.DomainAddress(domain) addr := v2net.DomainAddress(domain)
v2netassert.Address(addr).IsDomain() assert.Address(addr).IsDomain()
v2netassert.Address(addr).IsNotIPv6() assert.Address(addr).IsNotIPv6()
v2netassert.Address(addr).IsNotIPv4() assert.Address(addr).IsNotIPv4()
assert.StringLiteral(addr.Domain()).Equals(domain) assert.StringLiteral(addr.Domain()).Equals(domain)
assert.String(addr).Equals("v2ray.com") assert.String(addr).Equals("v2ray.com")
} }
@ -71,7 +70,7 @@ func TestNetIPv4Address(t *testing.T) {
ip := net.IPv4(1, 2, 3, 4) ip := net.IPv4(1, 2, 3, 4)
addr := v2net.IPAddress(ip) addr := v2net.IPAddress(ip)
v2netassert.Address(addr).IsIPv4() assert.Address(addr).IsIPv4()
assert.String(addr).Equals("1.2.3.4") assert.String(addr).Equals("1.2.3.4")
} }

View File

@ -4,7 +4,6 @@ import (
"testing" "testing"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
) )
@ -13,8 +12,8 @@ func TestTCPDestination(t *testing.T) {
v2testing.Current(t) v2testing.Current(t)
dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80) dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
v2netassert.Destination(dest).IsTCP() assert.Destination(dest).IsTCP()
v2netassert.Destination(dest).IsNotUDP() assert.Destination(dest).IsNotUDP()
assert.String(dest).Equals("tcp:1.2.3.4:80") assert.String(dest).Equals("tcp:1.2.3.4:80")
} }
@ -22,8 +21,8 @@ func TestUDPDestination(t *testing.T) {
v2testing.Current(t) v2testing.Current(t)
dest := v2net.UDPDestination(v2net.IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}), 53) dest := v2net.UDPDestination(v2net.IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}), 53)
v2netassert.Destination(dest).IsNotTCP() assert.Destination(dest).IsNotTCP()
v2netassert.Destination(dest).IsUDP() assert.Destination(dest).IsUDP()
assert.String(dest).Equals("udp:[2001:4860:4860::8888]:53") assert.String(dest).Equals("udp:[2001:4860:4860::8888]:53")
} }

View File

@ -4,7 +4,6 @@ import (
"testing" "testing"
"github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/alloc"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
"github.com/v2ray/v2ray-core/common/protocol" "github.com/v2ray/v2ray-core/common/protocol"
. "github.com/v2ray/v2ray-core/common/protocol/raw" . "github.com/v2ray/v2ray-core/common/protocol/raw"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
@ -34,7 +33,7 @@ func TestSwitchAccount(t *testing.T) {
assert.Bool(ok).IsTrue() assert.Bool(ok).IsTrue()
assert.Pointer(sa.Host).IsNil() assert.Pointer(sa.Host).IsNil()
assert.Pointer(sa2.Host).IsNil() assert.Pointer(sa2.Host).IsNil()
netassert.Port(sa.Port).Equals(sa2.Port) assert.Port(sa.Port).Equals(sa2.Port)
assert.String(sa.ID).Equals(sa2.ID.String()) assert.String(sa.ID).Equals(sa2.ID.String())
assert.Uint16(sa.AlterIds.Value()).Equals(sa2.AlterIds.Value()) assert.Uint16(sa.AlterIds.Value()).Equals(sa2.AlterIds.Value())
assert.Byte(byte(sa.Level)).Equals(byte(sa2.Level)) assert.Byte(byte(sa.Level)).Equals(byte(sa2.Level))

View File

@ -5,7 +5,6 @@ import (
"github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/alloc"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
"github.com/v2ray/v2ray-core/common/protocol" "github.com/v2ray/v2ray-core/common/protocol"
. "github.com/v2ray/v2ray-core/common/protocol/raw" . "github.com/v2ray/v2ray-core/common/protocol/raw"
"github.com/v2ray/v2ray-core/common/uuid" "github.com/v2ray/v2ray-core/common/uuid"
@ -45,6 +44,6 @@ func TestRequestSerialization(t *testing.T) {
assert.Byte(expectedRequest.Version).Equals(actualRequest.Version) assert.Byte(expectedRequest.Version).Equals(actualRequest.Version)
assert.Byte(byte(expectedRequest.Command)).Equals(byte(actualRequest.Command)) assert.Byte(byte(expectedRequest.Command)).Equals(byte(actualRequest.Command))
assert.Byte(byte(expectedRequest.Option)).Equals(byte(actualRequest.Option)) assert.Byte(byte(expectedRequest.Option)).Equals(byte(actualRequest.Option))
netassert.Address(expectedRequest.Address).Equals(actualRequest.Address) assert.Address(expectedRequest.Address).Equals(actualRequest.Address)
netassert.Port(expectedRequest.Port).Equals(actualRequest.Port) assert.Port(expectedRequest.Port).Equals(actualRequest.Port)
} }

View File

@ -10,7 +10,6 @@ import (
"github.com/v2ray/v2ray-core/app/proxyman" "github.com/v2ray/v2ray-core/app/proxyman"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
. "github.com/v2ray/v2ray-core/proxy/dokodemo" . "github.com/v2ray/v2ray-core/proxy/dokodemo"
"github.com/v2ray/v2ray-core/proxy/freedom" "github.com/v2ray/v2ray-core/proxy/freedom"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
@ -57,7 +56,7 @@ func TestDokodemoTCP(t *testing.T) {
port := v2nettesting.PickPort() port := v2nettesting.PickPort()
err = dokodemo.Listen(port) err = dokodemo.Listen(port)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Port(port).Equals(dokodemo.Port()) assert.Port(port).Equals(dokodemo.Port())
tcpClient, err := net.DialTCP("tcp", nil, &net.TCPAddr{ tcpClient, err := net.DialTCP("tcp", nil, &net.TCPAddr{
IP: []byte{127, 0, 0, 1}, IP: []byte{127, 0, 0, 1},
@ -115,7 +114,7 @@ func TestDokodemoUDP(t *testing.T) {
port := v2nettesting.PickPort() port := v2nettesting.PickPort()
err = dokodemo.Listen(port) err = dokodemo.Listen(port)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Port(port).Equals(dokodemo.Port()) assert.Port(port).Equals(dokodemo.Port())
udpClient, err := net.DialUDP("udp", nil, &net.UDPAddr{ udpClient, err := net.DialUDP("udp", nil, &net.UDPAddr{
IP: []byte{127, 0, 0, 1}, IP: []byte{127, 0, 0, 1},
@ -130,6 +129,6 @@ func TestDokodemoUDP(t *testing.T) {
response := make([]byte, 1024) response := make([]byte, 1024)
nBytes, addr, err := udpClient.ReadFromUDP(response) nBytes, addr, err := udpClient.ReadFromUDP(response)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.IP(addr.IP).Equals(v2net.LocalHostIP.IP()) assert.IP(addr.IP).Equals(v2net.LocalHostIP.IP())
assert.Bytes(response[:nBytes]).Equals([]byte("Processed: " + data2Send)) assert.Bytes(response[:nBytes]).Equals([]byte("Processed: " + data2Send))
} }

View File

@ -14,7 +14,6 @@ import (
"github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/alloc"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
. "github.com/v2ray/v2ray-core/proxy/freedom" . "github.com/v2ray/v2ray-core/proxy/freedom"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
@ -88,6 +87,6 @@ func TestIPResolution(t *testing.T) {
space.Initialize() space.Initialize()
ipDest := freedom.ResolveIP(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), v2net.Port(80))) ipDest := freedom.ResolveIP(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), v2net.Port(80)))
netassert.Destination(ipDest).IsTCP() assert.Destination(ipDest).IsTCP()
netassert.Address(ipDest.Address()).Equals(v2net.LocalHostIP) assert.Address(ipDest.Address()).Equals(v2net.LocalHostIP)
} }

View File

@ -8,7 +8,6 @@ import (
testdispatcher "github.com/v2ray/v2ray-core/app/dispatcher/testing" testdispatcher "github.com/v2ray/v2ray-core/app/dispatcher/testing"
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing" v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
. "github.com/v2ray/v2ray-core/proxy/http" . "github.com/v2ray/v2ray-core/proxy/http"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
@ -59,7 +58,7 @@ func TestNormalGetRequest(t *testing.T) {
port := v2nettesting.PickPort() port := v2nettesting.PickPort()
err := httpProxy.Listen(port) err := httpProxy.Listen(port)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Port(port).Equals(httpProxy.Port()) assert.Port(port).Equals(httpProxy.Port())
httpClient := &http.Client{} httpClient := &http.Client{}
resp, err := httpClient.Get("http://127.0.0.1:" + port.String() + "/") resp, err := httpClient.Get("http://127.0.0.1:" + port.String() + "/")

View File

@ -5,7 +5,6 @@ import (
"github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/alloc"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
"github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy"
. "github.com/v2ray/v2ray-core/proxy/shadowsocks" . "github.com/v2ray/v2ray-core/proxy/shadowsocks"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
@ -21,8 +20,8 @@ func TestNormalRequestParsing(t *testing.T) {
request, err := ReadRequest(buffer, nil, false) request, err := ReadRequest(buffer, nil, false)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Address(request.Address).Equals(v2net.LocalHostIP) assert.Address(request.Address).Equals(v2net.LocalHostIP)
netassert.Port(request.Port).Equals(v2net.Port(80)) assert.Port(request.Port).Equals(v2net.Port(80))
assert.Bool(request.OTA).IsFalse() assert.Bool(request.OTA).IsFalse()
} }
@ -85,7 +84,7 @@ func TestOTARequest(t *testing.T) {
[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5})) []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5}))
request, err := ReadRequest(buffer, auth, false) request, err := ReadRequest(buffer, auth, false)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Address(request.Address).Equals(v2net.DomainAddress("www.v2ray.com")) assert.Address(request.Address).Equals(v2net.DomainAddress("www.v2ray.com"))
assert.Bool(request.OTA).IsTrue() assert.Bool(request.OTA).IsTrue()
} }
@ -110,8 +109,8 @@ func TestUDPRequestParsing(t *testing.T) {
request, err := ReadRequest(buffer, nil, true) request, err := ReadRequest(buffer, nil, true)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Address(request.Address).Equals(v2net.LocalHostIP) assert.Address(request.Address).Equals(v2net.LocalHostIP)
netassert.Port(request.Port).Equals(v2net.Port(80)) assert.Port(request.Port).Equals(v2net.Port(80))
assert.Bool(request.OTA).IsFalse() assert.Bool(request.OTA).IsFalse()
assert.Bytes(request.UDPPayload.Value).Equals([]byte{1, 2, 3, 4, 5, 6}) assert.Bytes(request.UDPPayload.Value).Equals([]byte{1, 2, 3, 4, 5, 6})
} }
@ -130,7 +129,7 @@ func TestUDPRequestWithOTA(t *testing.T) {
[]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5})) []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5}))
request, err := ReadRequest(buffer, auth, true) request, err := ReadRequest(buffer, auth, true)
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Address(request.Address).Equals(v2net.DomainAddress("www.v2ray.com")) assert.Address(request.Address).Equals(v2net.DomainAddress("www.v2ray.com"))
assert.Bool(request.OTA).IsTrue() assert.Bool(request.OTA).IsTrue()
assert.Bytes(request.UDPPayload.Value).Equals([]byte{ assert.Bytes(request.UDPPayload.Value).Equals([]byte{
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0}) 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0})

View File

@ -6,7 +6,6 @@ import (
"github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/alloc"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
) )
@ -24,7 +23,7 @@ func TestSocks4AuthenticationRequestRead(t *testing.T) {
assert.Error(err).Equals(Socks4Downgrade) assert.Error(err).Equals(Socks4Downgrade)
assert.Byte(request4.Version).Named("Version").Equals(0x04) assert.Byte(request4.Version).Named("Version").Equals(0x04)
assert.Byte(request4.Command).Named("Command").Equals(0x01) assert.Byte(request4.Command).Named("Command").Equals(0x01)
v2netassert.Port(request4.Port).Named("Port").Equals(v2net.Port(53)) assert.Port(request4.Port).Named("Port").Equals(v2net.Port(53))
assert.Bytes(request4.IP[:]).Named("IP").Equals([]byte{0x72, 0x72, 0x72, 0x72}) assert.Bytes(request4.IP[:]).Named("IP").Equals([]byte{0x72, 0x72, 0x72, 0x72})
} }

View File

@ -7,7 +7,6 @@ import (
"github.com/v2ray/v2ray-core/common/alloc" "github.com/v2ray/v2ray-core/common/alloc"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
v2netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
"github.com/v2ray/v2ray-core/proxy" "github.com/v2ray/v2ray-core/proxy"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
@ -71,7 +70,7 @@ func TestRequestRead(t *testing.T) {
assert.Byte(request.Command).Named("Command").Equals(0x01) assert.Byte(request.Command).Named("Command").Equals(0x01)
assert.Byte(request.AddrType).Named("Address Type").Equals(0x01) assert.Byte(request.AddrType).Named("Address Type").Equals(0x01)
assert.Bytes(request.IPv4[:]).Named("IPv4").Equals([]byte{0x72, 0x72, 0x72, 0x72}) assert.Bytes(request.IPv4[:]).Named("IPv4").Equals([]byte{0x72, 0x72, 0x72, 0x72})
v2netassert.Port(request.Port).Named("Port").Equals(v2net.Port(53)) assert.Port(request.Port).Named("Port").Equals(v2net.Port(53))
} }
func TestResponseWrite(t *testing.T) { func TestResponseWrite(t *testing.T) {
@ -170,5 +169,5 @@ func TestIPv6Request(t *testing.T) {
assert.Error(err).IsNil() assert.Error(err).IsNil()
assert.Byte(request.Command).Equals(1) assert.Byte(request.Command).Equals(1)
assert.Bytes(request.IPv6[:]).Equals([]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6}) assert.Bytes(request.IPv6[:]).Equals([]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6})
v2netassert.Port(request.Port).Equals(8) assert.Port(request.Port).Equals(8)
} }

View File

@ -4,7 +4,6 @@ import (
"testing" "testing"
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert" "github.com/v2ray/v2ray-core/testing/assert"
"github.com/v2ray/v2ray-core/transport" "github.com/v2ray/v2ray-core/transport"
@ -34,6 +33,6 @@ func TestDomainAddressRequest(t *testing.T) {
assert.Byte(request.Fragment).Equals(1) assert.Byte(request.Fragment).Equals(1)
assert.String(request.Address).Equals("v2ray.com") assert.String(request.Address).Equals("v2ray.com")
netassert.Port(request.Port).Equals(v2net.Port(80)) assert.Port(request.Port).Equals(v2net.Port(80))
assert.Bytes(request.Data.Value).Equals([]byte("Actual payload")) assert.Bytes(request.Data.Value).Equals([]byte("Actual payload"))
} }

View File

@ -9,7 +9,6 @@ import (
"testing" "testing"
_ "github.com/v2ray/v2ray-core/app/router/rules" _ "github.com/v2ray/v2ray-core/app/router/rules"
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
. "github.com/v2ray/v2ray-core/shell/point" . "github.com/v2ray/v2ray-core/shell/point"
v2testing "github.com/v2ray/v2ray-core/testing" v2testing "github.com/v2ray/v2ray-core/testing"
@ -25,7 +24,7 @@ func TestClientSampleConfig(t *testing.T) {
pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json")) pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_socks_vmess.json"))
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Port(pointConfig.Port).IsValid() assert.Port(pointConfig.Port).IsValid()
assert.Pointer(pointConfig.InboundConfig).IsNotNil() assert.Pointer(pointConfig.InboundConfig).IsNotNil()
assert.Pointer(pointConfig.OutboundConfig).IsNotNil() assert.Pointer(pointConfig.OutboundConfig).IsNotNil()
@ -45,7 +44,7 @@ func TestServerSampleConfig(t *testing.T) {
pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json")) pointConfig, err := LoadConfig(filepath.Join(baseDir, "vpoint_vmess_freedom.json"))
assert.Error(err).IsNil() assert.Error(err).IsNil()
netassert.Port(pointConfig.Port).IsValid() assert.Port(pointConfig.Port).IsValid()
assert.Pointer(pointConfig.InboundConfig).IsNotNil() assert.Pointer(pointConfig.InboundConfig).IsNotNil()
assert.Pointer(pointConfig.OutboundConfig).IsNotNil() assert.Pointer(pointConfig.OutboundConfig).IsNotNil()

View File

@ -3,7 +3,6 @@ package assert
import ( import (
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/testing/assert"
) )
func Address(value v2net.Address) *AddressSubject { func Address(value v2net.Address) *AddressSubject {
@ -11,7 +10,7 @@ func Address(value v2net.Address) *AddressSubject {
} }
type AddressSubject struct { type AddressSubject struct {
assert.Subject Subject
value v2net.Address value v2net.Address
} }

View File

@ -3,7 +3,6 @@ package assert
import ( import (
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/testing/assert"
) )
func Destination(value v2net.Destination) *DestinationSubject { func Destination(value v2net.Destination) *DestinationSubject {
@ -11,7 +10,7 @@ func Destination(value v2net.Destination) *DestinationSubject {
} }
type DestinationSubject struct { type DestinationSubject struct {
assert.Subject Subject
value v2net.Destination value v2net.Destination
} }

View File

@ -5,7 +5,6 @@ import (
"net" "net"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/testing/assert"
) )
func IP(value net.IP) *IPSubject { func IP(value net.IP) *IPSubject {
@ -13,7 +12,7 @@ func IP(value net.IP) *IPSubject {
} }
type IPSubject struct { type IPSubject struct {
assert.Subject Subject
value net.IP value net.IP
} }

View File

@ -3,7 +3,6 @@ package assert
import ( import (
v2net "github.com/v2ray/v2ray-core/common/net" v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/serial" "github.com/v2ray/v2ray-core/common/serial"
"github.com/v2ray/v2ray-core/testing/assert"
) )
func Port(value v2net.Port) *PortSubject { func Port(value v2net.Port) *PortSubject {
@ -11,7 +10,7 @@ func Port(value v2net.Port) *PortSubject {
} }
type PortSubject struct { type PortSubject struct {
assert.Subject Subject
value v2net.Port value v2net.Port
} }