mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 22:45:13 +00:00
simplify testing
This commit is contained in:
1 parent
3582b9d869
commit
fc63f0432c
99 files changed
+726
-817
No files matched your search
@@ -5,13 +5,12 @@ import (
|
||||
"testing"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
"github.com/v2ray/v2ray-core/testing/servers/tcp"
|
||||
)
|
||||
|
||||
func TestDokodemoTCP(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
tcpServer := &tcp.Server{
|
||||
Port: v2net.Port(50016),
|
||||
@@ -47,7 +46,7 @@ func TestDokodemoTCP(t *testing.T) {
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
assert.String("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@ import (
|
||||
"testing"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
"github.com/v2ray/v2ray-core/testing/servers/tcp"
|
||||
)
|
||||
|
||||
func TestDynamicVMess(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
tcpServer := &tcp.Server{
|
||||
Port: v2net.Port(50032),
|
||||
@@ -47,7 +46,7 @@ func TestDynamicVMess(t *testing.T) {
|
||||
response := bytes.NewBuffer(nil)
|
||||
_, err = io.Copy(response, conn)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral("Processed: " + payload).Equals(string(response.Bytes()))
|
||||
assert.String("Processed: " + payload).Equals(string(response.Bytes()))
|
||||
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
@@ -7,13 +7,12 @@ import (
|
||||
"testing"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
v2http "github.com/v2ray/v2ray-core/testing/servers/http"
|
||||
)
|
||||
|
||||
func TestHttpProxy(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
httpServer := &v2http.Server{
|
||||
Port: v2net.Port(50042),
|
||||
@@ -41,7 +40,7 @@ func TestHttpProxy(t *testing.T) {
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral(string(content)).Equals("Home")
|
||||
assert.String(string(content)).Equals("Home")
|
||||
|
||||
CloseAllServers()
|
||||
}
|
||||
@@ -5,13 +5,12 @@ import (
|
||||
"testing"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
"github.com/v2ray/v2ray-core/testing/servers/tcp"
|
||||
)
|
||||
|
||||
func TestRouter(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
tcpServer := &tcp.Server{
|
||||
Port: v2net.Port(50024),
|
||||
@@ -56,7 +55,7 @@ func TestRouter(t *testing.T) {
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
assert.String("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
conn.Close()
|
||||
|
||||
conn, err = net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
"github.com/v2ray/v2ray-core/testing/servers/tcp"
|
||||
|
||||
@@ -13,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestShadowsocksTCP(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
tcpServer := &tcp.Server{
|
||||
Port: v2net.Port(50052),
|
||||
@@ -47,7 +46,7 @@ func TestShadowsocksTCP(t *testing.T) {
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
assert.String("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
conn.Close()
|
||||
|
||||
cipher, err = ssclient.NewCipher("aes-128-cfb", "v2ray-another")
|
||||
@@ -66,7 +65,7 @@ func TestShadowsocksTCP(t *testing.T) {
|
||||
response = make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
assert.String("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
conn.Close()
|
||||
|
||||
cipher, err = ssclient.NewCipher("chacha20", "new-password")
|
||||
@@ -85,7 +84,7 @@ func TestShadowsocksTCP(t *testing.T) {
|
||||
response = make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert.Error(err).IsNil()
|
||||
assert.StringLiteral("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
assert.String("Processed: " + payload).Equals(string(response[:nBytes]))
|
||||
conn.Close()
|
||||
|
||||
CloseAllServers()
|
||||
|
||||
@@ -6,14 +6,13 @@ import (
|
||||
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
|
||||
v2testing "github.com/v2ray/v2ray-core/testing"
|
||||
"github.com/v2ray/v2ray-core/testing/assert"
|
||||
"github.com/v2ray/v2ray-core/testing/servers/tcp"
|
||||
"github.com/v2ray/v2ray-core/testing/servers/udp"
|
||||
)
|
||||
|
||||
func TestTCPConnection(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
targetPort := v2nettesting.PickPort()
|
||||
tcpServer := &tcp.Server{
|
||||
@@ -79,7 +78,7 @@ func TestTCPConnection(t *testing.T) {
|
||||
nResponse += nBytes
|
||||
conn.CloseWrite()
|
||||
|
||||
assert.StringLiteral(string(actualResponse[:nResponse])).Equals("Processed: Request to target server.Processed: Request to target server again.")
|
||||
assert.String(string(actualResponse[:nResponse])).Equals("Processed: Request to target server.Processed: Request to target server again.")
|
||||
|
||||
conn.Close()
|
||||
}
|
||||
@@ -88,7 +87,7 @@ func TestTCPConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTCPBind(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
targetPort := v2nettesting.PickPort()
|
||||
tcpServer := &tcp.Server{
|
||||
@@ -139,7 +138,7 @@ func TestTCPBind(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUDPAssociate(t *testing.T) {
|
||||
v2testing.Current(t)
|
||||
assert := assert.On(t)
|
||||
|
||||
targetPort := v2nettesting.PickPort()
|
||||
udpServer := &udp.Server{
|
||||
|
||||
Reference in new issue
Block a user