mirror of https://github.com/v2ray/v2ray-core
remove common/compare package
parent
4468c60b95
commit
d26700a2fe
|
@ -7,10 +7,11 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
. "v2ray.com/core/common/buf"
|
. "v2ray.com/core/common/buf"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
"v2ray.com/core/testing/servers/tcp"
|
"v2ray.com/core/testing/servers/tcp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ func TestReadvReader(t *testing.T) {
|
||||||
rdata := make([]byte, size)
|
rdata := make([]byte, size)
|
||||||
SplitBytes(rmb, rdata)
|
SplitBytes(rmb, rdata)
|
||||||
|
|
||||||
if err := compare.BytesEqualWithDetail(data, rdata); err != nil {
|
if r := cmp.Diff(data, rdata); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
package compare
|
|
||||||
|
|
||||||
import "v2ray.com/core/common/errors"
|
|
||||||
|
|
||||||
func BytesEqualWithDetail(a []byte, b []byte) error {
|
|
||||||
if len(a) != len(b) {
|
|
||||||
return errors.New("mismatch array length ", len(a), " vs ", len(b))
|
|
||||||
}
|
|
||||||
for idx, v := range a {
|
|
||||||
if b[idx] != v {
|
|
||||||
return errors.New("mismatch array value at index [", idx, "]: ", v, " vs ", b[idx])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func BytesEqual(a []byte, b []byte) bool {
|
|
||||||
return BytesEqualWithDetail(a, b) == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func BytesAll(arr []byte, value byte) bool {
|
|
||||||
for _, v := range arr {
|
|
||||||
if v != value {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package compare_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
. "v2ray.com/core/common/compare"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestBytesEqual(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
Input1 []byte
|
|
||||||
Input2 []byte
|
|
||||||
Result bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
Input1: []byte{},
|
|
||||||
Input2: []byte{1},
|
|
||||||
Result: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Input1: nil,
|
|
||||||
Input2: []byte{},
|
|
||||||
Result: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Input1: []byte{1},
|
|
||||||
Input2: []byte{1},
|
|
||||||
Result: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Input1: []byte{1, 2},
|
|
||||||
Input2: []byte{1, 3},
|
|
||||||
Result: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
|
||||||
cmp := BytesEqual(testCase.Input1, testCase.Input2)
|
|
||||||
if cmp != testCase.Result {
|
|
||||||
t.Errorf("unexpected result %v from %v", cmp, testCase)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,8 +5,9 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
. "v2ray.com/core/common/crypto"
|
. "v2ray.com/core/common/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -49,8 +50,8 @@ func TestChaCha20Stream(t *testing.T) {
|
||||||
input := make([]byte, len(c.output))
|
input := make([]byte, len(c.output))
|
||||||
actualOutout := make([]byte, len(c.output))
|
actualOutout := make([]byte, len(c.output))
|
||||||
s.XORKeyStream(actualOutout, input)
|
s.XORKeyStream(actualOutout, input)
|
||||||
if err := compare.BytesEqualWithDetail(c.output, actualOutout); err != nil {
|
if r := cmp.Diff(c.output, actualOutout); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +71,7 @@ func TestChaCha20Decoding(t *testing.T) {
|
||||||
|
|
||||||
stream2 := NewChaCha20Stream(key, iv)
|
stream2 := NewChaCha20Stream(key, iv)
|
||||||
stream2.XORKeyStream(x, x)
|
stream2.XORKeyStream(x, x)
|
||||||
if err := compare.BytesEqualWithDetail(x, payload); err != nil {
|
if r := cmp.Diff(x, payload); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
package net
|
package net
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -90,6 +89,8 @@ func ParseAddress(addr string) Address {
|
||||||
return DomainAddress(addr)
|
return DomainAddress(addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bytes0 = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||||
|
|
||||||
// IPAddress creates an Address with given IP.
|
// IPAddress creates an Address with given IP.
|
||||||
func IPAddress(ip []byte) Address {
|
func IPAddress(ip []byte) Address {
|
||||||
switch len(ip) {
|
switch len(ip) {
|
||||||
|
@ -97,7 +98,7 @@ func IPAddress(ip []byte) Address {
|
||||||
var addr ipv4Address = [4]byte{ip[0], ip[1], ip[2], ip[3]}
|
var addr ipv4Address = [4]byte{ip[0], ip[1], ip[2], ip[3]}
|
||||||
return addr
|
return addr
|
||||||
case net.IPv6len:
|
case net.IPv6len:
|
||||||
if compare.BytesAll(ip[0:10], 0) && compare.BytesAll(ip[10:12], 0xff) {
|
if bytes.Equal(ip[:10], bytes0) && ip[10] == 0xff && ip[11] == 0xff {
|
||||||
return IPAddress(ip[12:16])
|
return IPAddress(ip[12:16])
|
||||||
}
|
}
|
||||||
var addr ipv6Address = [16]byte{
|
var addr ipv6Address = [16]byte{
|
||||||
|
|
|
@ -3,19 +3,11 @@ package protocol_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
. "v2ray.com/core/common/protocol"
|
. "v2ray.com/core/common/protocol"
|
||||||
"v2ray.com/core/common/uuid"
|
"v2ray.com/core/common/uuid"
|
||||||
. "v2ray.com/ext/assert"
|
. "v2ray.com/ext/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCmdKey(t *testing.T) {
|
|
||||||
assert := With(t)
|
|
||||||
|
|
||||||
id := NewID(uuid.New())
|
|
||||||
assert(compare.BytesAll(id.CmdKey(), 0), IsFalse)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIdEquals(t *testing.T) {
|
func TestIdEquals(t *testing.T) {
|
||||||
assert := With(t)
|
assert := With(t)
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
. "v2ray.com/core/common/uuid"
|
. "v2ray.com/core/common/uuid"
|
||||||
. "v2ray.com/ext/assert"
|
. "v2ray.com/ext/assert"
|
||||||
)
|
)
|
||||||
|
@ -33,8 +32,8 @@ func TestParseString(t *testing.T) {
|
||||||
|
|
||||||
uuid, err := ParseString(str)
|
uuid, err := ParseString(str)
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
if err := compare.BytesEqualWithDetail(expectedBytes, uuid.Bytes()); err != nil {
|
if r := cmp.Diff(expectedBytes, uuid.Bytes); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = ParseString("2418d087")
|
_, err = ParseString("2418d087")
|
||||||
|
|
|
@ -5,8 +5,9 @@ import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
. "v2ray.com/core/proxy/mtproto"
|
. "v2ray.com/core/proxy/mtproto"
|
||||||
. "v2ray.com/ext/assert"
|
. "v2ray.com/ext/assert"
|
||||||
)
|
)
|
||||||
|
@ -24,8 +25,8 @@ func TestInverse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bii := Inverse(bi)
|
bii := Inverse(bi)
|
||||||
if err := compare.BytesEqualWithDetail(bii, b); err != nil {
|
if r := cmp.Diff(bii, b); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package mtproto
|
package mtproto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/buf"
|
"v2ray.com/core/common/buf"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
"v2ray.com/core/common/crypto"
|
"v2ray.com/core/common/crypto"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
|
@ -63,11 +63,14 @@ func (s *Server) Network() []net.Network {
|
||||||
return []net.Network{net.Network_TCP}
|
return []net.Network{net.Network_TCP}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ctype1 = []byte{0xef, 0xef, 0xef, 0xef}
|
||||||
|
var ctype2 = []byte{0xee, 0xee, 0xee, 0xee}
|
||||||
|
|
||||||
func isValidConnectionType(c [4]byte) bool {
|
func isValidConnectionType(c [4]byte) bool {
|
||||||
if compare.BytesAll(c[:], 0xef) {
|
if bytes.Equal(c[:], ctype1) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if compare.BytesAll(c[:], 0xee) {
|
if bytes.Equal(c[:], ctype2) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
|
@ -18,7 +20,6 @@ import (
|
||||||
"v2ray.com/core/app/router"
|
"v2ray.com/core/app/router"
|
||||||
"v2ray.com/core/app/stats"
|
"v2ray.com/core/app/stats"
|
||||||
statscmd "v2ray.com/core/app/stats/command"
|
statscmd "v2ray.com/core/app/stats/command"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
"v2ray.com/core/common/serial"
|
"v2ray.com/core/common/serial"
|
||||||
|
@ -120,8 +121,8 @@ func TestCommanderRemoveHandler(t *testing.T) {
|
||||||
response := make([]byte, 1024)
|
response := make([]byte, 1024)
|
||||||
nBytes, err = conn.Read(response)
|
nBytes, err = conn.Read(response)
|
||||||
assert(err, IsNil)
|
assert(err, IsNil)
|
||||||
if err := compare.BytesEqualWithDetail(response[:nBytes], xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response[:nBytes], xor([]byte(payload))); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,8 +515,8 @@ func TestCommanderStats(t *testing.T) {
|
||||||
assert(nBytes, Equals, len(payload))
|
assert(nBytes, Equals, len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*20, 10240*1024)
|
response := readFrom(conn, time.Second*20, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Fatal("failed to read response: ", err)
|
t.Fatal("failed to read response: ", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock())
|
cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock())
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/app/log"
|
"v2ray.com/core/app/log"
|
||||||
"v2ray.com/core/app/policy"
|
"v2ray.com/core/app/policy"
|
||||||
|
@ -13,7 +14,6 @@ import (
|
||||||
"v2ray.com/core/app/reverse"
|
"v2ray.com/core/app/reverse"
|
||||||
"v2ray.com/core/app/router"
|
"v2ray.com/core/app/router"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
clog "v2ray.com/core/common/log"
|
clog "v2ray.com/core/common/log"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
|
@ -213,8 +213,8 @@ func TestReverseProxy(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*20, 10240*1024)
|
response := readFrom(conn, time.Second*20, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -428,8 +428,8 @@ func TestReverseProxyLongRunning(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*5, 1024)
|
response := readFrom(conn, time.Second*5, 1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"v2ray.com/core/app/log"
|
"v2ray.com/core/app/log"
|
||||||
"v2ray.com/core/app/proxyman"
|
"v2ray.com/core/app/proxyman"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
"v2ray.com/core/common/errors"
|
"v2ray.com/core/common/errors"
|
||||||
clog "v2ray.com/core/common/log"
|
clog "v2ray.com/core/common/log"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
|
@ -395,8 +394,8 @@ func TestShadowsocksChacha20TCP(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*20, 10240*1024)
|
response := readFrom(conn, time.Second*20, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -506,8 +505,8 @@ func TestShadowsocksChacha20Poly1305TCP(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*20, 10240*1024)
|
response := readFrom(conn, time.Second*20, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,13 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/app/proxyman"
|
"v2ray.com/core/app/proxyman"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
|
"v2ray.com/core/common/errors"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
"v2ray.com/core/common/protocol/tls/cert"
|
"v2ray.com/core/common/protocol/tls/cert"
|
||||||
|
@ -31,8 +35,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSimpleTLSConnection(t *testing.T) {
|
func TestSimpleTLSConnection(t *testing.T) {
|
||||||
assert := With(t)
|
|
||||||
|
|
||||||
tcpServer := tcp.Server{
|
tcpServer := tcp.Server{
|
||||||
MsgProcessor: xor,
|
MsgProcessor: xor,
|
||||||
}
|
}
|
||||||
|
@ -127,21 +129,35 @@ func TestSimpleTLSConnection(t *testing.T) {
|
||||||
common.Must(err)
|
common.Must(err)
|
||||||
defer CloseAllServers(servers)
|
defer CloseAllServers(servers)
|
||||||
|
|
||||||
{
|
var errg errgroup.Group
|
||||||
|
errg.Go(func() error {
|
||||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||||
IP: []byte{127, 0, 0, 1},
|
IP: []byte{127, 0, 0, 1},
|
||||||
Port: int(clientPort),
|
Port: int(clientPort),
|
||||||
})
|
})
|
||||||
assert(err, IsNil)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
payload := make([]byte, 1024)
|
||||||
|
common.Must2(rand.Read(payload))
|
||||||
|
|
||||||
payload := "dokodemo request."
|
|
||||||
nBytes, err := conn.Write([]byte(payload))
|
nBytes, err := conn.Write([]byte(payload))
|
||||||
assert(err, IsNil)
|
common.Must(err)
|
||||||
assert(nBytes, Equals, len(payload))
|
if nBytes != len(payload) {
|
||||||
|
return errors.New("expected ", len(payload), " written, but actually ", nBytes)
|
||||||
|
}
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*2, len(payload))
|
response := readFrom(conn, time.Second*2, len(payload))
|
||||||
assert(response, Equals, xor([]byte(payload)))
|
if r := cmp.Diff(response, xor(payload)); r != "" {
|
||||||
assert(conn.Close(), IsNil)
|
return errors.New(r)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := errg.Wait(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"v2ray.com/core/transport/internet/headers/wechat"
|
"v2ray.com/core/transport/internet/headers/wechat"
|
||||||
|
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/app/log"
|
"v2ray.com/core/app/log"
|
||||||
"v2ray.com/core/app/proxyman"
|
"v2ray.com/core/app/proxyman"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
clog "v2ray.com/core/common/log"
|
clog "v2ray.com/core/common/log"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
|
@ -427,8 +427,8 @@ func TestVMessQuic(t *testing.T) {
|
||||||
assert(nBytes, Equals, len(payload))
|
assert(nBytes, Equals, len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*40, 10240*1024)
|
response := readFrom(conn, time.Second*40, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"v2ray.com/core"
|
"v2ray.com/core"
|
||||||
"v2ray.com/core/app/log"
|
"v2ray.com/core/app/log"
|
||||||
"v2ray.com/core/app/proxyman"
|
"v2ray.com/core/app/proxyman"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
clog "v2ray.com/core/common/log"
|
clog "v2ray.com/core/common/log"
|
||||||
"v2ray.com/core/common/net"
|
"v2ray.com/core/common/net"
|
||||||
"v2ray.com/core/common/protocol"
|
"v2ray.com/core/common/protocol"
|
||||||
|
@ -289,8 +289,8 @@ func TestVMessGCM(t *testing.T) {
|
||||||
assert(nBytes, Equals, len(payload))
|
assert(nBytes, Equals, len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*40, 10240*1024)
|
response := readFrom(conn, time.Second*40, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -420,8 +420,8 @@ func TestVMessGCMReadv(t *testing.T) {
|
||||||
assert(nBytes, Equals, len(payload))
|
assert(nBytes, Equals, len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Second*40, 10240*1024)
|
response := readFrom(conn, time.Second*40, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor([]byte(payload))); err != nil {
|
if r := cmp.Diff(response, xor([]byte(payload))); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -934,8 +934,8 @@ func TestVMessKCP(t *testing.T) {
|
||||||
assert(nBytes, Equals, len(payload))
|
assert(nBytes, Equals, len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Minute*2, 10240*1024)
|
response := readFrom(conn, time.Minute*2, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor(payload)); err != nil {
|
if r := cmp.Diff(response, xor(payload)); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -1105,8 +1105,8 @@ func TestVMessKCPLarge(t *testing.T) {
|
||||||
assert(nBytes, Equals, len(payload))
|
assert(nBytes, Equals, len(payload))
|
||||||
|
|
||||||
response := readFrom(conn, time.Minute*10, 10240*1024)
|
response := readFrom(conn, time.Minute*10, 10240*1024)
|
||||||
if err := compare.BytesEqualWithDetail(response, xor(payload)); err != nil {
|
if r := cmp.Diff(response, xor(payload)); r != "" {
|
||||||
t.Error(err)
|
t.Error(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
"v2ray.com/core/common"
|
"v2ray.com/core/common"
|
||||||
"v2ray.com/core/common/buf"
|
"v2ray.com/core/common/buf"
|
||||||
"v2ray.com/core/common/compare"
|
|
||||||
"v2ray.com/core/testing/servers/tcp"
|
"v2ray.com/core/testing/servers/tcp"
|
||||||
. "v2ray.com/core/transport/internet"
|
. "v2ray.com/core/transport/internet"
|
||||||
)
|
)
|
||||||
|
@ -34,7 +34,7 @@ func TestTCPFastOpen(t *testing.T) {
|
||||||
|
|
||||||
b := buf.New()
|
b := buf.New()
|
||||||
common.Must2(b.ReadFrom(conn))
|
common.Must2(b.ReadFrom(conn))
|
||||||
if err := compare.BytesEqualWithDetail(b.Bytes(), []byte("abcd")); err != nil {
|
if r := cmp.Diff(b.Bytes(), []byte("abcd")); r != "" {
|
||||||
t.Fatal(err)
|
t.Fatal(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue