Explorar o código

simplify testing

v2ray %!s(int64=9) %!d(string=hai) anos
pai
achega
fc63f0432c
Modificáronse 99 ficheiros con 726 adicións e 817 borrados
  1. 1 2
      app/dns/config_json_test.go
  2. 1 2
      app/dns/server_test.go
  3. 2 3
      app/router/rules/chinaip_json_test.go
  4. 1 2
      app/router/rules/chinaip_test.go
  5. 2 3
      app/router/rules/chinasites_json_test.go
  6. 1 2
      app/router/rules/chinasites_test.go
  7. 7 7
      app/router/rules/condition.go
  8. 2 3
      app/router/rules/config_json_test.go
  9. 3 2
      app/router/rules/router.go
  10. 2 3
      app/router/rules/router_test.go
  11. 5 6
      common/alloc/buffer_test.go
  12. 4 6
      common/collect/validity_map.go
  13. 2 3
      common/crypto/chacha20_test.go
  14. 1 2
      common/io/buffered_reader_test.go
  15. 1 2
      common/io/buffered_writer_test.go
  16. 1 2
      common/io/reader_test.go
  17. 1 2
      common/io/writer_test.go
  18. 3 2
      common/log/access.go
  19. 5 6
      common/log/internal/log_entry.go
  20. 5 6
      common/log/internal/log_entry_test.go
  21. 4 5
      common/net/address_json_test.go
  22. 19 20
      common/net/address_test.go
  23. 6 7
      common/net/destination_test.go
  24. 4 3
      common/net/ipnet_test.go
  25. 3 4
      common/net/network_json_test.go
  26. 3 3
      common/net/port.go
  27. 5 6
      common/net/port_json_test.go
  28. 1 2
      common/net/port_test.go
  29. 1 2
      common/net/timed_io_test.go
  30. 1 2
      common/protocol/headers.go
  31. 1 2
      common/protocol/id_test.go
  32. 2 2
      common/protocol/raw/commands.go
  33. 3 4
      common/protocol/raw/commands_test.go
  34. 1 2
      common/protocol/raw/encoding_test.go
  35. 1 2
      common/protocol/time_test.go
  36. 4 5
      common/protocol/user_json_test.go
  37. 4 5
      common/retry/retry_test.go
  38. 16 2
      common/serial/bytes.go
  39. 9 0
      common/serial/interface.go
  40. 16 0
      common/serial/numbers.go
  41. 3 4
      common/serial/string_json_test.go
  42. 1 2
      common/serial/string_list_json_test.go
  43. 0 24
      common/serial/string_test.go
  44. 9 10
      common/uuid/uuid_test.go
  45. 3 4
      proxy/dokodemo/dokodemo_test.go
  46. 3 4
      proxy/freedom/freedom_test.go
  47. 1 2
      proxy/http/config_json_test.go
  48. 12 13
      proxy/http/server_test.go
  49. 2 3
      proxy/internal/config/config_cache_test.go
  50. 1 2
      proxy/shadowsocks/config_json_test.go
  51. 1 2
      proxy/shadowsocks/ota_test.go
  52. 10 11
      proxy/shadowsocks/protocol_test.go
  53. 2 3
      proxy/socks/config_json_test.go
  54. 6 7
      proxy/socks/protocol/socks4_test.go
  55. 22 23
      proxy/socks/protocol/socks_test.go
  56. 3 4
      proxy/socks/protocol/udp_test.go
  57. 6 7
      proxy/socks/server_test.go
  58. 1 2
      proxy/vmess/inbound/command.go
  59. 3 4
      proxy/vmess/io/io_test.go
  60. 1 1
      proxy/vmess/io/writer.go
  61. 1 1
      proxy/vmess/outbound/command.go
  62. 3 4
      proxy/vmess/outbound/receiver_json_test.go
  63. 1 2
      proxy/vmess/outbound/receiver_test.go
  64. 1 2
      proxy/vmess/vmess_test.go
  65. 8 9
      shell/point/config_json_test.go
  66. 31 17
      testing/assert/address.go
  67. 13 9
      testing/assert/assert.go
  68. 42 0
      testing/assert/bool.go
  69. 0 49
      testing/assert/boolsubject.go
  70. 38 0
      testing/assert/byte.go
  71. 34 0
      testing/assert/bytes.go
  72. 0 41
      testing/assert/bytessubject.go
  73. 0 45
      testing/assert/bytesubject.go
  74. 26 16
      testing/assert/destination.go
  75. 38 0
      testing/assert/error.go
  76. 0 41
      testing/assert/errorsubject.go
  77. 44 0
      testing/assert/int64.go
  78. 0 51
      testing/assert/int64subject.go
  79. 15 18
      testing/assert/intsubject.go
  80. 10 15
      testing/assert/ip.go
  81. 38 0
      testing/assert/pointer.go
  82. 0 45
      testing/assert/pointersubject.go
  83. 12 16
      testing/assert/port.go
  84. 44 0
      testing/assert/string.go
  85. 0 53
      testing/assert/stringsubject.go
  86. 8 24
      testing/assert/subject.go
  87. 50 0
      testing/assert/uint16.go
  88. 0 47
      testing/assert/uint16subject.go
  89. 2 3
      testing/scenarios/dokodemo_test.go
  90. 2 3
      testing/scenarios/dynamic_vmess_test.go
  91. 2 3
      testing/scenarios/http_test.go
  92. 2 3
      testing/scenarios/router_test.go
  93. 4 5
      testing/scenarios/shadowsocks_test.go
  94. 4 5
      testing/scenarios/socks_end_test.go
  95. 1 2
      tools/build/build_test.go
  96. 2 3
      tools/build/env_test.go
  97. 2 3
      tools/build/go_test.go
  98. 2 3
      tools/git/git_test.go
  99. 2 3
      transport/dialer/dialer_test.go

+ 1 - 2
app/dns/config_json_test.go

@@ -8,12 +8,11 @@ import (
 
 	. "github.com/v2ray/v2ray-core/app/dns"
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestConfigParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := `{
     "servers": ["8.8.8.8"]

+ 1 - 2
app/dns/server_test.go

@@ -11,12 +11,11 @@ import (
 	"github.com/v2ray/v2ray-core/app/proxyman"
 	v2net "github.com/v2ray/v2ray-core/common/net"
 	"github.com/v2ray/v2ray-core/proxy/freedom"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestDnsAdd(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	space := app.NewSpace()
 

+ 2 - 3
app/router/rules/chinaip_json_test.go

@@ -6,18 +6,17 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/app/router/rules"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestChinaIPJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rule := ParseRule([]byte(`{
     "type": "chinaip",
     "outboundTag": "x"
   }`))
-	assert.StringLiteral(rule.Tag).Equals("x")
+	assert.String(rule.Tag).Equals("x")
 	assert.Bool(rule.Apply(makeDestination("121.14.1.189"))).IsTrue()    // sina.com.cn
 	assert.Bool(rule.Apply(makeDestination("101.226.103.106"))).IsTrue() // qq.com
 	assert.Bool(rule.Apply(makeDestination("115.239.210.36"))).IsTrue()  // image.baidu.com

+ 1 - 2
app/router/rules/chinaip_test.go

@@ -6,7 +6,6 @@ import (
 
 	. "github.com/v2ray/v2ray-core/app/router/rules"
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
@@ -15,7 +14,7 @@ func makeDestination(ip string) v2net.Destination {
 }
 
 func TestChinaIP(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rule := NewChinaIPRule("tag")
 	assert.Bool(rule.Apply(makeDestination("121.14.1.189"))).IsTrue()    // sina.com.cn

+ 2 - 3
app/router/rules/chinasites_json_test.go

@@ -6,18 +6,17 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/app/router/rules"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestChinaSitesJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rule := ParseRule([]byte(`{
     "type": "chinasites",
     "outboundTag": "y"
   }`))
-	assert.StringLiteral(rule.Tag).Equals("y")
+	assert.String(rule.Tag).Equals("y")
 	assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()
 	assert.Bool(rule.Apply(makeDomainDestination("www.163.com"))).IsTrue()
 	assert.Bool(rule.Apply(makeDomainDestination("ngacn.cc"))).IsTrue()

+ 1 - 2
app/router/rules/chinasites_test.go

@@ -5,7 +5,6 @@ import (
 
 	. "github.com/v2ray/v2ray-core/app/router/rules"
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
@@ -14,7 +13,7 @@ func makeDomainDestination(domain string) v2net.Destination {
 }
 
 func TestChinaSites(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rule := NewChinaSitesRule("tag")
 	assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()

+ 7 - 7
app/router/rules/condition.go

@@ -3,9 +3,9 @@ package rules
 import (
 	"net"
 	"regexp"
+	"strings"
 
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
 type Condition interface {
@@ -63,12 +63,12 @@ func (this *AnyCondition) Len() int {
 }
 
 type PlainDomainMatcher struct {
-	pattern serial.StringT
+	pattern string
 }
 
 func NewPlainDomainMatcher(pattern string) *PlainDomainMatcher {
 	return &PlainDomainMatcher{
-		pattern: serial.StringT(pattern),
+		pattern: pattern,
 	}
 }
 
@@ -76,8 +76,8 @@ func (this *PlainDomainMatcher) Apply(dest v2net.Destination) bool {
 	if !dest.Address().IsDomain() {
 		return false
 	}
-	domain := serial.StringT(dest.Address().Domain())
-	return domain.Contains(this.pattern)
+	domain := dest.Address().Domain()
+	return strings.Contains(domain, this.pattern)
 }
 
 type RegexpDomainMatcher struct {
@@ -98,8 +98,8 @@ func (this *RegexpDomainMatcher) Apply(dest v2net.Destination) bool {
 	if !dest.Address().IsDomain() {
 		return false
 	}
-	domain := serial.StringT(dest.Address().Domain())
-	return this.pattern.MatchString(domain.ToLower().String())
+	domain := dest.Address().Domain()
+	return this.pattern.MatchString(strings.ToLower(domain))
 }
 
 type CIDRMatcher struct {

+ 2 - 3
app/router/rules/config_json_test.go

@@ -7,12 +7,11 @@ import (
 
 	. "github.com/v2ray/v2ray-core/app/router/rules"
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestDomainRule(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rule := ParseRule([]byte(`{
     "type": "field",
@@ -33,7 +32,7 @@ func TestDomainRule(t *testing.T) {
 }
 
 func TestIPRule(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rule := ParseRule([]byte(`{
     "type": "field",

+ 3 - 2
app/router/rules/router.go

@@ -108,10 +108,11 @@ func (this *Router) takeDetourWithoutCache(dest v2net.Destination) (string, erro
 }
 
 func (this *Router) TakeDetour(dest v2net.Destination) (string, error) {
-	rawEntry := this.cache.Get(dest)
+	destStr := dest.String()
+	rawEntry := this.cache.Get(destStr)
 	if rawEntry == nil {
 		tag, err := this.takeDetourWithoutCache(dest)
-		this.cache.Set(dest, newCacheEntry(tag, err))
+		this.cache.Set(destStr, newCacheEntry(tag, err))
 		return tag, err
 	}
 	entry := rawEntry.(*cacheEntry)

+ 2 - 3
app/router/rules/router_test.go

@@ -11,12 +11,11 @@ import (
 	"github.com/v2ray/v2ray-core/app/router"
 	. "github.com/v2ray/v2ray-core/app/router/rules"
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestSimpleRouter(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	config := &RouterRuleConfig{
 		Rules: []*Rule{
@@ -37,5 +36,5 @@ func TestSimpleRouter(t *testing.T) {
 
 	tag, err := r.TakeDetour(v2net.TCPDestination(v2net.DomainAddress("v2ray.com"), 80))
 	assert.Error(err).IsNil()
-	assert.StringLiteral(tag).Equals("test")
+	assert.String(tag).Equals("test")
 }

+ 5 - 6
common/alloc/buffer_test.go

@@ -4,12 +4,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/alloc"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestBufferClear(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := NewBuffer().Clear()
 	defer buffer.Release()
@@ -23,7 +22,7 @@ func TestBufferClear(t *testing.T) {
 }
 
 func TestBufferIsFull(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := NewBuffer()
 	defer buffer.Release()
@@ -35,7 +34,7 @@ func TestBufferIsFull(t *testing.T) {
 }
 
 func TestBufferPrepend(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := NewBuffer().Clear()
 	defer buffer.Release()
@@ -51,11 +50,11 @@ func TestBufferPrepend(t *testing.T) {
 }
 
 func TestBufferString(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := NewBuffer().Clear()
 	defer buffer.Release()
 
 	buffer.AppendString("Test String")
-	assert.String(buffer).Equals("Test String")
+	assert.String(buffer.String()).Equals("Test String")
 }

+ 4 - 6
common/collect/validity_map.go

@@ -3,8 +3,6 @@ package collect
 import (
 	"sync"
 	"sync/atomic"
-
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
 type Validity interface {
@@ -51,9 +49,9 @@ func (this *ValidityMap) cleanup() {
 	}
 }
 
-func (this *ValidityMap) Set(key serial.String, value Validity) {
+func (this *ValidityMap) Set(key string, value Validity) {
 	this.Lock()
-	this.cache[key.String()] = value
+	this.cache[key] = value
 	this.Unlock()
 	opCount := atomic.AddInt32(&this.opCount, 1)
 	if opCount > 1000 {
@@ -62,10 +60,10 @@ func (this *ValidityMap) Set(key serial.String, value Validity) {
 	}
 }
 
-func (this *ValidityMap) Get(key serial.String) Validity {
+func (this *ValidityMap) Get(key string) Validity {
 	this.RLock()
 	defer this.RUnlock()
-	if value, found := this.cache[key.String()]; found {
+	if value, found := this.cache[key]; found {
 		return value
 	}
 	return nil

+ 2 - 3
common/crypto/chacha20_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/crypto"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
@@ -19,7 +18,7 @@ func mustDecodeHex(s string) []byte {
 }
 
 func TestChaCha20Stream(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var cases = []struct {
 		key    []byte
@@ -58,7 +57,7 @@ func TestChaCha20Stream(t *testing.T) {
 }
 
 func TestChaCha20Decoding(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	key := make([]byte, 32)
 	rand.Read(key)

+ 1 - 2
common/io/buffered_reader_test.go

@@ -5,12 +5,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common/alloc"
 	. "github.com/v2ray/v2ray-core/common/io"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestBufferedReader(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	content := alloc.NewLargeBuffer()
 	len := content.Len()

+ 1 - 2
common/io/buffered_writer_test.go

@@ -5,12 +5,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common/alloc"
 	. "github.com/v2ray/v2ray-core/common/io"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestBufferedWriter(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	content := alloc.NewLargeBuffer().Clear()
 

+ 1 - 2
common/io/reader_test.go

@@ -6,12 +6,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common/alloc"
 	. "github.com/v2ray/v2ray-core/common/io"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestAdaptiveReader(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawContent := make([]byte, 1024*1024)
 

+ 1 - 2
common/io/writer_test.go

@@ -7,12 +7,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common/alloc"
 	. "github.com/v2ray/v2ray-core/common/io"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestAdaptiveWriter(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	lb := alloc.NewLargeBuffer()
 	rand.Read(lb.Value)

+ 3 - 2
common/log/access.go

@@ -1,8 +1,9 @@
 package log
 
 import (
+	"fmt"
+
 	"github.com/v2ray/v2ray-core/common/log/internal"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
 // AccessStatus is the status of an access request from clients.
@@ -29,7 +30,7 @@ func InitAccessLogger(file string) error {
 }
 
 // Access writes an access log.
-func Access(from, to serial.String, status AccessStatus, reason serial.String) {
+func Access(from, to fmt.Stringer, status AccessStatus, reason fmt.Stringer) {
 	accessLoggerInstance.Log(&internal.AccessLog{
 		From:   from,
 		To:     to,

+ 5 - 6
common/log/internal/log_entry.go

@@ -5,12 +5,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common"
 	"github.com/v2ray/v2ray-core/common/alloc"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
 type LogEntry interface {
 	common.Releasable
-	serial.String
+	fmt.Stringer
 }
 
 type ErrorLog struct {
@@ -37,7 +36,7 @@ func (this *ErrorLog) String() string {
 			b.AppendString(typedVal)
 		case *string:
 			b.AppendString(*typedVal)
-		case serial.String:
+		case fmt.Stringer:
 			b.AppendString(typedVal.String())
 		case error:
 			b.AppendString(typedVal.Error())
@@ -49,10 +48,10 @@ func (this *ErrorLog) String() string {
 }
 
 type AccessLog struct {
-	From   serial.String
-	To     serial.String
+	From   fmt.Stringer
+	To     fmt.Stringer
 	Status string
-	Reason serial.String
+	Reason fmt.Stringer
 }
 
 func (this *AccessLog) Release() {

+ 5 - 6
common/log/internal/log_entry_test.go

@@ -5,12 +5,11 @@ import (
 
 	. "github.com/v2ray/v2ray-core/common/log/internal"
 	"github.com/v2ray/v2ray-core/common/serial"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestAccessLog(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	entry := &AccessLog{
 		From:   serial.StringT("test_from"),
@@ -20,8 +19,8 @@ func TestAccessLog(t *testing.T) {
 	}
 
 	entryStr := entry.String()
-	assert.StringLiteral(entryStr).Contains(serial.StringT("test_from"))
-	assert.StringLiteral(entryStr).Contains(serial.StringT("test_to"))
-	assert.StringLiteral(entryStr).Contains(serial.StringT("test_reason"))
-	assert.StringLiteral(entryStr).Contains(serial.StringT("Accepted"))
+	assert.String(entryStr).Contains("test_from")
+	assert.String(entryStr).Contains("test_to")
+	assert.String(entryStr).Contains("test_reason")
+	assert.String(entryStr).Contains("Accepted")
 }

+ 4 - 5
common/net/address_json_test.go

@@ -8,12 +8,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestIPParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := "\"8.8.8.8\""
 	var address AddressJson
@@ -25,7 +24,7 @@ func TestIPParsing(t *testing.T) {
 }
 
 func TestDomainParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := "\"v2ray.com\""
 	var address AddressJson
@@ -33,11 +32,11 @@ func TestDomainParsing(t *testing.T) {
 	assert.Error(err).IsNil()
 	assert.Bool(address.Address.IsIPv4()).IsFalse()
 	assert.Bool(address.Address.IsDomain()).IsTrue()
-	assert.StringLiteral(address.Address.Domain()).Equals("v2ray.com")
+	assert.String(address.Address.Domain()).Equals("v2ray.com")
 }
 
 func TestInvalidAddressJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := "1234"
 	var address AddressJson

+ 19 - 20
common/net/address_test.go

@@ -5,12 +5,11 @@ import (
 	"testing"
 
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestIPv4Address(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	ip := []byte{byte(1), byte(2), byte(3), byte(4)}
 	addr := v2net.IPAddress(ip)
@@ -19,11 +18,11 @@ func TestIPv4Address(t *testing.T) {
 	assert.Address(addr).IsNotIPv6()
 	assert.Address(addr).IsNotDomain()
 	assert.Bytes(addr.IP()).Equals(ip)
-	assert.String(addr).Equals("1.2.3.4")
+	assert.Address(addr).EqualsString("1.2.3.4")
 }
 
 func TestIPv6Address(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	ip := []byte{
 		byte(1), byte(2), byte(3), byte(4),
@@ -36,12 +35,12 @@ func TestIPv6Address(t *testing.T) {
 	assert.Address(addr).IsIPv6()
 	assert.Address(addr).IsNotIPv4()
 	assert.Address(addr).IsNotDomain()
-	assert.Bytes(addr.IP()).Equals(ip)
-	assert.String(addr).Equals("[102:304:102:304:102:304:102:304]")
+	assert.IP(addr.IP()).Equals(net.IP(ip))
+	assert.Address(addr).EqualsString("[102:304:102:304:102:304:102:304]")
 }
 
 func TestIPv4Asv6(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	ip := []byte{
 		byte(0), byte(0), byte(0), byte(0),
 		byte(0), byte(0), byte(0), byte(0),
@@ -49,11 +48,11 @@ func TestIPv4Asv6(t *testing.T) {
 		byte(1), byte(2), byte(3), byte(4),
 	}
 	addr := v2net.IPAddress(ip)
-	assert.String(addr).Equals("1.2.3.4")
+	assert.Address(addr).EqualsString("1.2.3.4")
 }
 
 func TestDomainAddress(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	domain := "v2ray.com"
 	addr := v2net.DomainAddress(domain)
@@ -61,37 +60,37 @@ func TestDomainAddress(t *testing.T) {
 	assert.Address(addr).IsDomain()
 	assert.Address(addr).IsNotIPv6()
 	assert.Address(addr).IsNotIPv4()
-	assert.StringLiteral(addr.Domain()).Equals(domain)
-	assert.String(addr).Equals("v2ray.com")
+	assert.String(addr.Domain()).Equals(domain)
+	assert.Address(addr).EqualsString("v2ray.com")
 }
 
 func TestNetIPv4Address(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	ip := net.IPv4(1, 2, 3, 4)
 	addr := v2net.IPAddress(ip)
 	assert.Address(addr).IsIPv4()
-	assert.String(addr).Equals("1.2.3.4")
+	assert.Address(addr).EqualsString("1.2.3.4")
 }
 
 func TestIPv4AddressEquals(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	addr := v2net.IPAddress([]byte{1, 2, 3, 4})
-	assert.Bool(addr.Equals(nil)).IsFalse()
+	assert.Address(addr).NotEquals(nil)
 
 	addr2 := v2net.IPAddress([]byte{1, 2, 3, 4})
-	assert.Bool(addr.Equals(addr2)).IsTrue()
+	assert.Address(addr).Equals(addr2)
 
 	addr3 := v2net.IPAddress([]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6})
-	assert.Bool(addr.Equals(addr3)).IsFalse()
+	assert.Address(addr).NotEquals(addr3)
 
 	addr4 := v2net.IPAddress([]byte{1, 2, 3, 5})
-	assert.Bool(addr.Equals(addr4)).IsFalse()
+	assert.Address(addr).NotEquals(addr4)
 }
 
 func TestIPv6AddressEquals(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	addr := v2net.IPAddress([]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6})
 	assert.Bool(addr.Equals(nil)).IsFalse()
@@ -107,7 +106,7 @@ func TestIPv6AddressEquals(t *testing.T) {
 }
 
 func TestDomainAddressEquals(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	addr := v2net.DomainAddress("v2ray.com")
 	assert.Bool(addr.Equals(nil)).IsFalse()

+ 6 - 7
common/net/destination_test.go

@@ -4,30 +4,29 @@ import (
 	"testing"
 
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestTCPDestination(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
 	assert.Destination(dest).IsTCP()
 	assert.Destination(dest).IsNotUDP()
-	assert.String(dest).Equals("tcp:1.2.3.4:80")
+	assert.Destination(dest).EqualsString("tcp:1.2.3.4:80")
 }
 
 func TestUDPDestination(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	dest := v2net.UDPDestination(v2net.IPAddress([]byte{0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x88}), 53)
 	assert.Destination(dest).IsNotTCP()
 	assert.Destination(dest).IsUDP()
-	assert.String(dest).Equals("udp:[2001:4860:4860::8888]:53")
+	assert.Destination(dest).EqualsString("udp:[2001:4860:4860::8888]:53")
 }
 
 func TestTCPDestinationEquals(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	dest := v2net.TCPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
 	assert.Bool(dest.Equals(nil)).IsFalse()
@@ -43,7 +42,7 @@ func TestTCPDestinationEquals(t *testing.T) {
 }
 
 func TestUDPDestinationEquals(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	dest := v2net.UDPDestination(v2net.IPAddress([]byte{1, 2, 3, 4}), 80)
 	assert.Bool(dest.Equals(nil)).IsFalse()

+ 4 - 3
common/net/ipnet_test.go

@@ -5,18 +5,19 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func parseCIDR(str string) *net.IPNet {
 	_, ipNet, err := net.ParseCIDR(str)
-	assert.Error(err).IsNil()
+	if err != nil {
+		panic(err)
+	}
 	return ipNet
 }
 
 func TestIPNet(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	ipNet := NewIPNet()
 	ipNet.Add(parseCIDR(("0.0.0.0/8")))

+ 3 - 4
common/net/network_json_test.go

@@ -7,12 +7,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestArrayNetworkList(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var list NetworkList
 	err := json.Unmarshal([]byte("[\"Tcp\"]"), &list)
@@ -22,7 +21,7 @@ func TestArrayNetworkList(t *testing.T) {
 }
 
 func TestStringNetworkList(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var list NetworkList
 	err := json.Unmarshal([]byte("\"TCP, ip\""), &list)
@@ -32,7 +31,7 @@ func TestStringNetworkList(t *testing.T) {
 }
 
 func TestInvalidNetworkJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var list NetworkList
 	err := json.Unmarshal([]byte("0"), &list)

+ 3 - 3
common/net/port.go

@@ -13,7 +13,7 @@ var (
 )
 
 // Port represents a network port in TCP and UDP protocol.
-type Port serial.Uint16Literal
+type Port uint16
 
 // PortFromBytes converts a byte array to a Port, assuming bytes are in big endian order.
 // @unsafe Caller must ensure that the byte array has at least 2 elements.
@@ -47,12 +47,12 @@ func (this Port) Value() uint16 {
 
 // Bytes returns the correspoding bytes of this Port, in big endian order.
 func (this Port) Bytes() []byte {
-	return serial.Uint16Literal(this).Bytes()
+	return serial.Uint16ToBytes(this.Value())
 }
 
 // String returns the string presentation of this Port.
 func (this Port) String() string {
-	return serial.Uint16Literal(this).String()
+	return serial.Uint16ToString(this.Value())
 }
 
 // PortRange represents a range of ports.

+ 5 - 6
common/net/port_json_test.go

@@ -7,12 +7,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestIntPort(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var portRange PortRange
 	err := json.Unmarshal([]byte("1234"), &portRange)
@@ -23,7 +22,7 @@ func TestIntPort(t *testing.T) {
 }
 
 func TestOverRangeIntPort(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var portRange PortRange
 	err := json.Unmarshal([]byte("70000"), &portRange)
@@ -34,7 +33,7 @@ func TestOverRangeIntPort(t *testing.T) {
 }
 
 func TestSingleStringPort(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var portRange PortRange
 	err := json.Unmarshal([]byte("\"1234\""), &portRange)
@@ -45,7 +44,7 @@ func TestSingleStringPort(t *testing.T) {
 }
 
 func TestStringPairPort(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var portRange PortRange
 	err := json.Unmarshal([]byte("\"1234-5678\""), &portRange)
@@ -56,7 +55,7 @@ func TestStringPairPort(t *testing.T) {
 }
 
 func TestOverRangeStringPort(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var portRange PortRange
 	err := json.Unmarshal([]byte("\"65536\""), &portRange)

+ 1 - 2
common/net/port_test.go

@@ -4,12 +4,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestPortRangeContains(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	portRange := &PortRange{
 		From: Port(53),

+ 1 - 2
common/net/timed_io_test.go

@@ -4,12 +4,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestTimeOutSettings(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	reader := NewTimeOutReader(8, nil)
 	assert.Int(reader.GetTimeOut()).Equals(8)

+ 1 - 2
common/protocol/headers.go

@@ -2,7 +2,6 @@ package protocol
 
 import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	"github.com/v2ray/v2ray-core/common/serial"
 	"github.com/v2ray/v2ray-core/common/uuid"
 )
 
@@ -49,7 +48,7 @@ type CommandSwitchAccount struct {
 	Host     v2net.Address
 	Port     v2net.Port
 	ID       *uuid.UUID
-	AlterIds serial.Uint16Literal
+	AlterIds uint16
 	Level    UserLevel
 	ValidMin byte
 }

+ 1 - 2
common/protocol/id_test.go

@@ -6,12 +6,11 @@ import (
 	. "github.com/v2ray/v2ray-core/common/protocol"
 	"github.com/v2ray/v2ray-core/common/serial"
 	"github.com/v2ray/v2ray-core/common/uuid"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestCmdKey(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	id := NewID(uuid.New())
 	assert.Bool(serial.BytesT(id.CmdKey()).All(0)).IsFalse()

+ 2 - 2
common/protocol/raw/commands.go

@@ -99,7 +99,7 @@ func (this *CommandSwitchAccountFactory) Marshal(command interface{}, writer io.
 	idBytes := cmd.ID.Bytes()
 	writer.Write(idBytes)
 
-	writer.Write(cmd.AlterIds.Bytes())
+	writer.Write(serial.Uint16ToBytes(cmd.AlterIds))
 	writer.Write([]byte{byte(cmd.Level)})
 
 	writer.Write([]byte{cmd.ValidMin})
@@ -132,7 +132,7 @@ func (this *CommandSwitchAccountFactory) Unmarshal(data []byte) (interface{}, er
 	if len(data) < alterIdStart+2 {
 		return nil, transport.ErrorCorruptedPacket
 	}
-	cmd.AlterIds = serial.BytesT(data[alterIdStart : alterIdStart+2]).Uint16()
+	cmd.AlterIds = serial.BytesToUint16(data[alterIdStart : alterIdStart+2])
 	levelStart := alterIdStart + 2
 	if len(data) < levelStart+1 {
 		return nil, transport.ErrorCorruptedPacket

+ 3 - 4
common/protocol/raw/commands_test.go

@@ -7,12 +7,11 @@ import (
 	"github.com/v2ray/v2ray-core/common/protocol"
 	. "github.com/v2ray/v2ray-core/common/protocol/raw"
 	"github.com/v2ray/v2ray-core/common/uuid"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestSwitchAccount(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	sa := &protocol.CommandSwitchAccount{
 		Port:     1234,
@@ -34,8 +33,8 @@ func TestSwitchAccount(t *testing.T) {
 	assert.Pointer(sa.Host).IsNil()
 	assert.Pointer(sa2.Host).IsNil()
 	assert.Port(sa.Port).Equals(sa2.Port)
-	assert.String(sa.ID).Equals(sa2.ID.String())
-	assert.Uint16(sa.AlterIds.Value()).Equals(sa2.AlterIds.Value())
+	assert.String(sa.ID.String()).Equals(sa2.ID.String())
+	assert.Uint16(sa.AlterIds).Equals(sa2.AlterIds)
 	assert.Byte(byte(sa.Level)).Equals(byte(sa2.Level))
 	assert.Byte(sa.ValidMin).Equals(sa2.ValidMin)
 }

+ 1 - 2
common/protocol/raw/encoding_test.go

@@ -8,12 +8,11 @@ import (
 	"github.com/v2ray/v2ray-core/common/protocol"
 	. "github.com/v2ray/v2ray-core/common/protocol/raw"
 	"github.com/v2ray/v2ray-core/common/uuid"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestRequestSerialization(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	user := protocol.NewUser(
 		protocol.NewID(uuid.New()),

+ 1 - 2
common/protocol/time_test.go

@@ -5,12 +5,11 @@ import (
 	"time"
 
 	. "github.com/v2ray/v2ray-core/common/protocol"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestGenerateRandomInt64InRange(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	base := time.Now().Unix()
 	delta := 100

+ 4 - 5
common/protocol/user_json_test.go

@@ -7,12 +7,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/protocol"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestUserParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	user := new(User)
 	err := json.Unmarshal([]byte(`{
@@ -22,12 +21,12 @@ func TestUserParsing(t *testing.T) {
     "alterId": 100
   }`), user)
 	assert.Error(err).IsNil()
-	assert.String(user.ID).Equals("96edb838-6d68-42ef-a933-25f7ac3a9d09")
+	assert.String(user.ID.String()).Equals("96edb838-6d68-42ef-a933-25f7ac3a9d09")
 	assert.Byte(byte(user.Level)).Equals(1)
 }
 
 func TestInvalidUserJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	user := new(User)
 	err := json.Unmarshal([]byte(`{"id": 1234}`), user)
@@ -35,7 +34,7 @@ func TestInvalidUserJson(t *testing.T) {
 }
 
 func TestInvalidIdJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	user := new(User)
 	err := json.Unmarshal([]byte(`{"id": "1234"}`), user)

+ 4 - 5
common/retry/retry_test.go

@@ -6,7 +6,6 @@ import (
 	"time"
 
 	. "github.com/v2ray/v2ray-core/common/retry"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
@@ -15,7 +14,7 @@ var (
 )
 
 func TestNoRetry(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	startTime := time.Now().Unix()
 	err := Timed(10, 100000).On(func() error {
@@ -28,7 +27,7 @@ func TestNoRetry(t *testing.T) {
 }
 
 func TestRetryOnce(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	startTime := time.Now()
 	called := 0
@@ -46,7 +45,7 @@ func TestRetryOnce(t *testing.T) {
 }
 
 func TestRetryMultiple(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	startTime := time.Now()
 	called := 0
@@ -64,7 +63,7 @@ func TestRetryMultiple(t *testing.T) {
 }
 
 func TestRetryExhausted(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	startTime := time.Now()
 	called := 0

+ 16 - 2
common/serial/bytes.go

@@ -2,10 +2,24 @@ package serial
 
 import (
 	"bytes"
+	"encoding/hex"
+	"strings"
 )
 
-type Bytes interface {
-	Bytes() []byte
+func ByteToHexString(value byte) string {
+	return hex.EncodeToString([]byte{value})
+}
+
+func BytesToUint16(value []byte) uint16 {
+	return uint16(value[0])<<8 + uint16(value[1])
+}
+
+func BytesToHexString(value []byte) string {
+	strs := make([]string, len(value))
+	for i, b := range value {
+		strs[i] = hex.EncodeToString([]byte{b})
+	}
+	return "[" + strings.Join(strs, ",") + "]"
 }
 
 type BytesT []byte

+ 9 - 0
common/serial/interface.go

@@ -0,0 +1,9 @@
+package serial
+
+import (
+	"fmt"
+)
+
+func PointerToString(value interface{}) string {
+	return fmt.Sprint(value)
+}

+ 16 - 0
common/serial/numbers.go

@@ -4,6 +4,22 @@ import (
 	"strconv"
 )
 
+func Uint16ToBytes(value uint16) []byte {
+	return []byte{byte(value >> 8), byte(value)}
+}
+
+func Uint16ToString(value uint16) string {
+	return strconv.Itoa(int(value))
+}
+
+func IntToString(value int) string {
+	return Int64ToString(int64(value))
+}
+
+func Int64ToString(value int64) string {
+	return strconv.FormatInt(value, 10)
+}
+
 type Uint16 interface {
 	Value() uint16
 }

+ 3 - 4
common/serial/string_json_test.go

@@ -7,12 +7,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/serial"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestInvalidStringTJson(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var s StringT
 	err := json.Unmarshal([]byte("1"), &s)
@@ -20,10 +19,10 @@ func TestInvalidStringTJson(t *testing.T) {
 }
 
 func TestStringTParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var s StringT
 	err := json.Unmarshal([]byte("\"1\""), &s)
 	assert.Error(err).IsNil()
-	assert.String(s).Equals("1")
+	assert.String(s.String()).Equals("1")
 }

+ 1 - 2
common/serial/string_list_json_test.go

@@ -7,12 +7,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/serial"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestStringListUnmarshalError(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := `1234`
 	list := new(StringTList)

+ 0 - 24
common/serial/string_test.go

@@ -1,24 +0,0 @@
-package serial_test
-
-import (
-	"testing"
-
-	. "github.com/v2ray/v2ray-core/common/serial"
-	v2testing "github.com/v2ray/v2ray-core/testing"
-	"github.com/v2ray/v2ray-core/testing/assert"
-)
-
-type TestString struct {
-	value string
-}
-
-func (this *TestString) String() string {
-	return this.value
-}
-
-func TestNewStringSerial(t *testing.T) {
-	v2testing.Current(t)
-
-	testString := &TestString{value: "abcd"}
-	assert.String(NewStringT(testString)).Equals("abcd")
-}

+ 9 - 10
common/uuid/uuid_test.go

@@ -4,26 +4,25 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/common/uuid"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestParseBytes(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	str := "2418d087-648d-4990-86e8-19dca1d006d3"
 	bytes := []byte{0x24, 0x18, 0xd0, 0x87, 0x64, 0x8d, 0x49, 0x90, 0x86, 0xe8, 0x19, 0xdc, 0xa1, 0xd0, 0x06, 0xd3}
 
 	uuid, err := ParseBytes(bytes)
 	assert.Error(err).IsNil()
-	assert.String(uuid).Equals(str)
+	assert.String(uuid.String()).Equals(str)
 
 	_, err = ParseBytes([]byte{1, 3, 2, 4})
 	assert.Error(err).Equals(ErrorInvalidID)
 }
 
 func TestParseString(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	str := "2418d087-648d-4990-86e8-19dca1d006d3"
 	expectedBytes := []byte{0x24, 0x18, 0xd0, 0x87, 0x64, 0x8d, 0x49, 0x90, 0x86, 0xe8, 0x19, 0xdc, 0xa1, 0xd0, 0x06, 0xd3}
@@ -40,28 +39,28 @@ func TestParseString(t *testing.T) {
 }
 
 func TestNewUUID(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	uuid := New()
 	uuid2, err := ParseString(uuid.String())
 
 	assert.Error(err).IsNil()
-	assert.StringLiteral(uuid.String()).Equals(uuid2.String())
+	assert.String(uuid.String()).Equals(uuid2.String())
 	assert.Bytes(uuid.Bytes()).Equals(uuid2.Bytes())
 }
 
 func TestRandom(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	uuid := New()
 	uuid2 := New()
 
-	assert.StringLiteral(uuid.String()).NotEquals(uuid2.String())
+	assert.String(uuid.String()).NotEquals(uuid2.String())
 	assert.Bytes(uuid.Bytes()).NotEquals(uuid2.Bytes())
 }
 
 func TestEquals(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	var uuid *UUID = nil
 	var uuid2 *UUID = nil
@@ -70,7 +69,7 @@ func TestEquals(t *testing.T) {
 }
 
 func TestNext(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	uuid := New()
 	uuid2 := uuid.Next()

+ 3 - 4
proxy/dokodemo/dokodemo_test.go

@@ -12,14 +12,13 @@ import (
 	v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
 	. "github.com/v2ray/v2ray-core/proxy/dokodemo"
 	"github.com/v2ray/v2ray-core/proxy/freedom"
-	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 TestDokodemoTCP(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	tcpServer := &tcp.Server{
 		Port: v2nettesting.PickPort(),
@@ -73,11 +72,11 @@ func TestDokodemoTCP(t *testing.T) {
 	assert.Error(err).IsNil()
 	tcpClient.Close()
 
-	assert.StringLiteral("Processed: " + data2Send).Equals(string(response[:nBytes]))
+	assert.String("Processed: " + data2Send).Equals(string(response[:nBytes]))
 }
 
 func TestDokodemoUDP(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	udpServer := &udp.Server{
 		Port: v2nettesting.PickPort(),

+ 3 - 4
proxy/freedom/freedom_test.go

@@ -15,14 +15,13 @@ import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
 	v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
 	. "github.com/v2ray/v2ray-core/proxy/freedom"
-	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/transport/ray"
 )
 
 func TestSinglePacket(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	port := v2nettesting.PickPort()
 
 	tcpServer := &tcp.Server{
@@ -56,7 +55,7 @@ func TestSinglePacket(t *testing.T) {
 }
 
 func TestUnreachableDestination(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	freedom := NewFreedomConnection(&Config{}, app.NewSpace())
 	traffic := ray.NewRay()
@@ -68,7 +67,7 @@ func TestUnreachableDestination(t *testing.T) {
 }
 
 func TestIPResolution(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	space := app.NewSpace()
 	space.BindApp(proxyman.APP_ID_OUTBOUND_MANAGER, proxyman.NewDefaultOutboundHandlerManager())

+ 1 - 2
proxy/http/config_json_test.go

@@ -8,12 +8,11 @@ import (
 
 	v2net "github.com/v2ray/v2ray-core/common/net"
 	. "github.com/v2ray/v2ray-core/proxy/http"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestOwnHosts(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := `{
     "ownHosts": [

+ 12 - 13
proxy/http/server_test.go

@@ -9,12 +9,11 @@ import (
 	testdispatcher "github.com/v2ray/v2ray-core/app/dispatcher/testing"
 	v2nettesting "github.com/v2ray/v2ray-core/common/net/testing"
 	. "github.com/v2ray/v2ray-core/proxy/http"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestHopByHopHeadersStrip(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawRequest := `GET /pkg/net/http/ HTTP/1.1
 Host: golang.org
@@ -33,22 +32,22 @@ Accept-Language: de,en;q=0.7,en-us;q=0.3
 	b := bufio.NewReader(strings.NewReader(rawRequest))
 	req, err := http.ReadRequest(b)
 	assert.Error(err).IsNil()
-	assert.StringLiteral(req.Header.Get("Foo")).Equals("foo")
-	assert.StringLiteral(req.Header.Get("Bar")).Equals("bar")
-	assert.StringLiteral(req.Header.Get("Connection")).Equals("keep-alive,Foo, Bar")
-	assert.StringLiteral(req.Header.Get("Proxy-Connection")).Equals("keep-alive")
-	assert.StringLiteral(req.Header.Get("Proxy-Authenticate")).Equals("abc")
+	assert.String(req.Header.Get("Foo")).Equals("foo")
+	assert.String(req.Header.Get("Bar")).Equals("bar")
+	assert.String(req.Header.Get("Connection")).Equals("keep-alive,Foo, Bar")
+	assert.String(req.Header.Get("Proxy-Connection")).Equals("keep-alive")
+	assert.String(req.Header.Get("Proxy-Authenticate")).Equals("abc")
 
 	StripHopByHopHeaders(req)
-	assert.StringLiteral(req.Header.Get("Connection")).Equals("close")
-	assert.StringLiteral(req.Header.Get("Foo")).Equals("")
-	assert.StringLiteral(req.Header.Get("Bar")).Equals("")
-	assert.StringLiteral(req.Header.Get("Proxy-Connection")).Equals("")
-	assert.StringLiteral(req.Header.Get("Proxy-Authenticate")).Equals("")
+	assert.String(req.Header.Get("Connection")).Equals("close")
+	assert.String(req.Header.Get("Foo")).Equals("")
+	assert.String(req.Header.Get("Bar")).Equals("")
+	assert.String(req.Header.Get("Proxy-Connection")).Equals("")
+	assert.String(req.Header.Get("Proxy-Authenticate")).Equals("")
 }
 
 func TestNormalGetRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	testPacketDispatcher := testdispatcher.NewTestPacketDispatcher(nil)
 

+ 2 - 3
proxy/internal/config/config_cache_test.go

@@ -3,12 +3,11 @@ package config
 import (
 	"testing"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestRegisterInboundConfig(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	initializeConfigCache()
 
 	protocol := "test_protocol"
@@ -29,7 +28,7 @@ func TestRegisterInboundConfig(t *testing.T) {
 }
 
 func TestRegisterOutboundConfig(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	initializeConfigCache()
 
 	protocol := "test_protocol"

+ 1 - 2
proxy/shadowsocks/config_json_test.go

@@ -6,12 +6,11 @@ import (
 	"encoding/json"
 	"testing"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestConfigParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := `{
     "method": "aes-128-cfb",

+ 1 - 2
proxy/shadowsocks/ota_test.go

@@ -5,12 +5,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common/alloc"
 	. "github.com/v2ray/v2ray-core/proxy/shadowsocks"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestNormalChunkReading(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewBuffer().Clear().AppendBytes(
 		0, 8, 39, 228, 69, 96, 133, 39, 254, 26, 201, 70, 11, 12, 13, 14, 15, 16, 17, 18)

+ 10 - 11
proxy/shadowsocks/protocol_test.go

@@ -7,13 +7,12 @@ import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
 	"github.com/v2ray/v2ray-core/proxy"
 	. "github.com/v2ray/v2ray-core/proxy/shadowsocks"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 	"github.com/v2ray/v2ray-core/transport"
 )
 
 func TestNormalRequestParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear()
 	buffer.AppendBytes(1, 127, 0, 0, 1, 0, 80)
@@ -26,7 +25,7 @@ func TestNormalRequestParsing(t *testing.T) {
 }
 
 func TestEmptyPayload(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear()
 	_, err := ReadRequest(buffer, nil, false)
@@ -34,7 +33,7 @@ func TestEmptyPayload(t *testing.T) {
 }
 
 func TestSingleBytePayload(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear().AppendBytes(1)
 	_, err := ReadRequest(buffer, nil, false)
@@ -42,7 +41,7 @@ func TestSingleBytePayload(t *testing.T) {
 }
 
 func TestWrongAddressType(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear().AppendBytes(5)
 	_, err := ReadRequest(buffer, nil, false)
@@ -50,7 +49,7 @@ func TestWrongAddressType(t *testing.T) {
 }
 
 func TestInsufficientAddressRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear().AppendBytes(1, 1)
 	_, err := ReadRequest(buffer, nil, false)
@@ -66,7 +65,7 @@ func TestInsufficientAddressRequest(t *testing.T) {
 }
 
 func TestInsufficientPortRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear().AppendBytes(1, 1, 2, 3, 4, 5)
 	_, err := ReadRequest(buffer, nil, false)
@@ -74,7 +73,7 @@ func TestInsufficientPortRequest(t *testing.T) {
 }
 
 func TestOTARequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear()
 	buffer.AppendBytes(0x13, 13, 119, 119, 119, 46, 118, 50, 114, 97, 121, 46, 99, 111, 109, 0, 0, 239, 115, 52, 212, 178, 172, 26, 6, 168, 0)
@@ -89,7 +88,7 @@ func TestOTARequest(t *testing.T) {
 }
 
 func TestInvalidOTARequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear()
 	buffer.AppendBytes(0x13, 13, 119, 119, 119, 46, 118, 50, 114, 97, 121, 46, 99, 111, 109, 0, 0, 239, 115, 52, 212, 178, 172, 26, 6, 168, 1)
@@ -102,7 +101,7 @@ func TestInvalidOTARequest(t *testing.T) {
 }
 
 func TestUDPRequestParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear()
 	buffer.AppendBytes(1, 127, 0, 0, 1, 0, 80, 1, 2, 3, 4, 5, 6)
@@ -116,7 +115,7 @@ func TestUDPRequestParsing(t *testing.T) {
 }
 
 func TestUDPRequestWithOTA(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewSmallBuffer().Clear()
 	buffer.AppendBytes(

+ 2 - 3
proxy/socks/config_json_test.go

@@ -7,16 +7,15 @@ import (
 
 	"github.com/v2ray/v2ray-core/proxy/internal/config"
 	"github.com/v2ray/v2ray-core/proxy/socks"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestDefaultIPAddress(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	socksConfig, err := config.CreateInboundConfig("socks", []byte(`{
     "auth": "noauth"
   }`))
 	assert.Error(err).IsNil()
-	assert.String(socksConfig.(*socks.Config).Address).Equals("127.0.0.1")
+	assert.Address(socksConfig.(*socks.Config).Address).EqualsString("127.0.0.1")
 }

+ 6 - 7
proxy/socks/protocol/socks4_test.go

@@ -6,12 +6,11 @@ import (
 
 	"github.com/v2ray/v2ray-core/common/alloc"
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestSocks4AuthenticationRequestRead(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawRequest := []byte{
 		0x04, // version
@@ -21,14 +20,14 @@ func TestSocks4AuthenticationRequestRead(t *testing.T) {
 	}
 	_, request4, err := ReadAuthentication(bytes.NewReader(rawRequest))
 	assert.Error(err).Equals(Socks4Downgrade)
-	assert.Byte(request4.Version).Named("Version").Equals(0x04)
-	assert.Byte(request4.Command).Named("Command").Equals(0x01)
-	assert.Port(request4.Port).Named("Port").Equals(v2net.Port(53))
-	assert.Bytes(request4.IP[:]).Named("IP").Equals([]byte{0x72, 0x72, 0x72, 0x72})
+	assert.Byte(request4.Version).Equals(0x04)
+	assert.Byte(request4.Command).Equals(0x01)
+	assert.Port(request4.Port).Equals(v2net.Port(53))
+	assert.Bytes(request4.IP[:]).Equals([]byte{0x72, 0x72, 0x72, 0x72})
 }
 
 func TestSocks4AuthenticationResponseToBytes(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	response := NewSocks4AuthenticationResponse(byte(0x10), 443, []byte{1, 2, 3, 4})
 

+ 22 - 23
proxy/socks/protocol/socks_test.go

@@ -8,13 +8,12 @@ import (
 	"github.com/v2ray/v2ray-core/common/alloc"
 	v2net "github.com/v2ray/v2ray-core/common/net"
 	"github.com/v2ray/v2ray-core/proxy"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 	"github.com/v2ray/v2ray-core/transport"
 )
 
 func TestHasAuthenticationMethod(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	request := Socks5AuthenticationRequest{
 		version:     socksVersion,
@@ -29,7 +28,7 @@ func TestHasAuthenticationMethod(t *testing.T) {
 }
 
 func TestAuthenticationRequestRead(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewBuffer().Clear().AppendBytes(
 		0x05, // version
@@ -38,13 +37,13 @@ func TestAuthenticationRequestRead(t *testing.T) {
 	)
 	request, _, err := ReadAuthentication(buffer)
 	assert.Error(err).IsNil()
-	assert.Byte(request.version).Named("Version").Equals(0x05)
-	assert.Byte(request.nMethods).Named("#Methods").Equals(0x01)
-	assert.Byte(request.authMethods[0]).Named("Auth Method").Equals(0x02)
+	assert.Byte(request.version).Equals(0x05)
+	assert.Byte(request.nMethods).Equals(0x01)
+	assert.Byte(request.authMethods[0]).Equals(0x02)
 }
 
 func TestAuthenticationResponseWrite(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	response := NewAuthenticationResponse(byte(0x05))
 
@@ -54,7 +53,7 @@ func TestAuthenticationResponseWrite(t *testing.T) {
 }
 
 func TestRequestRead(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawRequest := []byte{
 		0x05,                   // version
@@ -66,15 +65,15 @@ func TestRequestRead(t *testing.T) {
 	}
 	request, err := ReadRequest(bytes.NewReader(rawRequest))
 	assert.Error(err).IsNil()
-	assert.Byte(request.Version).Named("Version").Equals(0x05)
-	assert.Byte(request.Command).Named("Command").Equals(0x01)
-	assert.Byte(request.AddrType).Named("Address Type").Equals(0x01)
-	assert.Bytes(request.IPv4[:]).Named("IPv4").Equals([]byte{0x72, 0x72, 0x72, 0x72})
-	assert.Port(request.Port).Named("Port").Equals(v2net.Port(53))
+	assert.Byte(request.Version).Equals(0x05)
+	assert.Byte(request.Command).Equals(0x01)
+	assert.Byte(request.AddrType).Equals(0x01)
+	assert.Bytes(request.IPv4[:]).Equals([]byte{0x72, 0x72, 0x72, 0x72})
+	assert.Port(request.Port).Equals(v2net.Port(53))
 }
 
 func TestResponseWrite(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	response := Socks5Response{
 		socksVersion,
@@ -97,11 +96,11 @@ func TestResponseWrite(t *testing.T) {
 		0x72, 0x72, 0x72, 0x72,
 		byte(0x00), byte(0x035),
 	}
-	assert.Bytes(buffer.Value).Named("raw response").Equals(expectedBytes)
+	assert.Bytes(buffer.Value).Equals(expectedBytes)
 }
 
 func TestSetIPv6(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	response := NewSocks5Response()
 	response.SetIPv6([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})
@@ -114,7 +113,7 @@ func TestSetIPv6(t *testing.T) {
 }
 
 func TestSetDomain(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	response := NewSocks5Response()
 	response.SetDomain("v2ray.com")
@@ -127,28 +126,28 @@ func TestSetDomain(t *testing.T) {
 }
 
 func TestEmptyAuthRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	_, _, err := ReadAuthentication(alloc.NewBuffer().Clear())
 	assert.Error(err).Equals(io.EOF)
 }
 
 func TestSingleByteAuthRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	_, _, err := ReadAuthentication(bytes.NewReader(make([]byte, 1)))
 	assert.Error(err).Equals(transport.ErrorCorruptedPacket)
 }
 
 func TestZeroAuthenticationMethod(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewBuffer().Clear().AppendBytes(5, 0)
 	_, _, err := ReadAuthentication(buffer)
 	assert.Error(err).Equals(proxy.ErrorInvalidAuthentication)
 }
 func TestWrongProtocolVersion(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewBuffer().Clear().AppendBytes(6, 1, 0)
 	_, _, err := ReadAuthentication(buffer)
@@ -156,14 +155,14 @@ func TestWrongProtocolVersion(t *testing.T) {
 }
 
 func TestEmptyRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	_, err := ReadRequest(alloc.NewBuffer().Clear())
 	assert.Error(err).Equals(io.EOF)
 }
 
 func TestIPv6Request(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	request, err := ReadRequest(alloc.NewBuffer().Clear().AppendBytes(5, 1, 0, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 0, 8))
 	assert.Error(err).IsNil()

+ 3 - 4
proxy/socks/protocol/udp_test.go

@@ -4,13 +4,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/transport"
 )
 
 func TestSingleByteUDPRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	request, err := ReadUDPRequest(make([]byte, 1))
 	if request != nil {
@@ -20,7 +19,7 @@ func TestSingleByteUDPRequest(t *testing.T) {
 }
 
 func TestDomainAddressRequest(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	payload := make([]byte, 0, 1024)
 	payload = append(payload, 0, 0, 1, AddrTypeDomain, byte(len("v2ray.com")))
@@ -32,7 +31,7 @@ func TestDomainAddressRequest(t *testing.T) {
 	assert.Error(err).IsNil()
 
 	assert.Byte(request.Fragment).Equals(1)
-	assert.String(request.Address).Equals("v2ray.com")
+	assert.Address(request.Address).EqualsString("v2ray.com")
 	assert.Port(request.Port).Equals(v2net.Port(80))
 	assert.Bytes(request.Data.Value).Equals([]byte("Actual payload"))
 }

+ 6 - 7
proxy/socks/server_test.go

@@ -17,12 +17,11 @@ import (
 	proxytesting "github.com/v2ray/v2ray-core/proxy/testing"
 	proxymocks "github.com/v2ray/v2ray-core/proxy/testing/mocks"
 	"github.com/v2ray/v2ray-core/shell/point"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestSocksTcpConnect(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	port := v2nettesting.PickPort()
 
 	connInput := []byte("The data to be returned to socks server.")
@@ -82,11 +81,11 @@ func TestSocksTcpConnect(t *testing.T) {
 
 	assert.Bytes([]byte(data2Send)).Equals(connOutput.Bytes())
 	assert.Bytes(dataReturned).Equals(connInput)
-	assert.StringLiteral(targetServer).Equals(och.Destination.NetAddr())
+	assert.String(targetServer).Equals(och.Destination.NetAddr())
 }
 
 func TestSocksTcpConnectWithUserPass(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	port := v2nettesting.PickPort()
 
 	connInput := []byte("The data to be returned to socks server.")
@@ -149,11 +148,11 @@ func TestSocksTcpConnectWithUserPass(t *testing.T) {
 
 	assert.Bytes([]byte(data2Send)).Equals(connOutput.Bytes())
 	assert.Bytes(dataReturned).Equals(connInput)
-	assert.StringLiteral(targetServer).Equals(och.Destination.NetAddr())
+	assert.String(targetServer).Equals(och.Destination.NetAddr())
 }
 
 func TestSocksTcpConnectWithWrongUserPass(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	port := v2nettesting.PickPort()
 
 	connInput := []byte("The data to be returned to socks server.")
@@ -206,7 +205,7 @@ func TestSocksTcpConnectWithWrongUserPass(t *testing.T) {
 }
 
 func TestSocksTcpConnectWithWrongAuthMethod(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	port := v2nettesting.PickPort()
 
 	connInput := []byte("The data to be returned to socks server.")

+ 1 - 2
proxy/vmess/inbound/command.go

@@ -3,7 +3,6 @@ package inbound
 import (
 	"github.com/v2ray/v2ray-core/common/log"
 	"github.com/v2ray/v2ray-core/common/protocol"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
 func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader) protocol.ResponseCommand {
@@ -23,7 +22,7 @@ func (this *VMessInboundHandler) generateCommand(request *protocol.RequestHeader
 				return &protocol.CommandSwitchAccount{
 					Port:     inboundHandler.Port(),
 					ID:       user.ID.UUID(),
-					AlterIds: serial.Uint16Literal(len(user.AlterIDs)),
+					AlterIds: uint16(len(user.AlterIDs)),
 					Level:    user.Level,
 					ValidMin: byte(availableMin),
 				}

+ 3 - 4
proxy/vmess/io/io_test.go

@@ -9,12 +9,11 @@ import (
 	"github.com/v2ray/v2ray-core/common/alloc"
 	v2io "github.com/v2ray/v2ray-core/common/io"
 	. "github.com/v2ray/v2ray-core/proxy/vmess/io"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestAuthenticate(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	buffer := alloc.NewBuffer().Clear()
 	buffer.AppendBytes(1, 2, 3, 4)
@@ -27,7 +26,7 @@ func TestAuthenticate(t *testing.T) {
 }
 
 func TestSingleIO(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	content := bytes.NewBuffer(make([]byte, 0, 1024*1024))
 
@@ -42,7 +41,7 @@ func TestSingleIO(t *testing.T) {
 }
 
 func TestLargeIO(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	content := make([]byte, 1024*1024)
 	rand.Read(content)

+ 1 - 1
proxy/vmess/io/writer.go

@@ -35,5 +35,5 @@ func Authenticate(buffer *alloc.Buffer) {
 	buffer.SliceBack(4)
 	fnvHash.Sum(buffer.Value[:0])
 
-	buffer.Prepend(serial.Uint16Literal(uint16(buffer.Len())).Bytes())
+	buffer.Prepend(serial.Uint16ToBytes(uint16(buffer.Len())))
 }

+ 1 - 1
proxy/vmess/outbound/command.go

@@ -7,7 +7,7 @@ import (
 
 func (this *VMessOutboundHandler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) {
 	primary := protocol.NewID(cmd.ID)
-	alters := protocol.NewAlterIDs(primary, cmd.AlterIds.Value())
+	alters := protocol.NewAlterIDs(primary, cmd.AlterIds)
 	user := protocol.NewUser(primary, alters, cmd.Level, "")
 	dest := v2net.TCPDestination(cmd.Host, cmd.Port)
 	this.receiverManager.AddDetour(NewReceiver(dest, user), cmd.ValidMin)

+ 3 - 4
proxy/vmess/outbound/receiver_json_test.go

@@ -7,12 +7,11 @@ import (
 	"testing"
 
 	. "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestConfigTargetParsing(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := `{
     "address": "127.0.0.1",
@@ -29,7 +28,7 @@ func TestConfigTargetParsing(t *testing.T) {
 	receiver := new(Receiver)
 	err := json.Unmarshal([]byte(rawJson), &receiver)
 	assert.Error(err).IsNil()
-	assert.String(receiver.Destination).Equals("tcp:127.0.0.1:80")
+	assert.Destination(receiver.Destination).EqualsString("tcp:127.0.0.1:80")
 	assert.Int(len(receiver.Accounts)).Equals(1)
-	assert.String(receiver.Accounts[0].ID).Equals("e641f5ad-9397-41e3-bf1a-e8740dfed019")
+	assert.String(receiver.Accounts[0].ID.String()).Equals("e641f5ad-9397-41e3-bf1a-e8740dfed019")
 }

+ 1 - 2
proxy/vmess/outbound/receiver_test.go

@@ -7,12 +7,11 @@ import (
 	"github.com/v2ray/v2ray-core/common/protocol"
 	"github.com/v2ray/v2ray-core/common/uuid"
 	. "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestReceiverUser(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	id := protocol.NewID(uuid.New())
 	alters := protocol.NewAlterIDs(id, 100)

+ 1 - 2
proxy/vmess/vmess_test.go

@@ -17,12 +17,11 @@ import (
 	_ "github.com/v2ray/v2ray-core/proxy/vmess/inbound"
 	_ "github.com/v2ray/v2ray-core/proxy/vmess/outbound"
 	"github.com/v2ray/v2ray-core/shell/point"
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestVMessInAndOut(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	id, err := uuid.ParseString("ad937d9d-6e23-4a5a-ba23-bce5092a7c51")
 	assert.Error(err).IsNil()

+ 8 - 9
shell/point/config_json_test.go

@@ -11,12 +11,11 @@ import (
 	_ "github.com/v2ray/v2ray-core/app/router/rules"
 	. "github.com/v2ray/v2ray-core/shell/point"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestClientSampleConfig(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	GOPATH := os.Getenv("GOPATH")
 	baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")
@@ -28,15 +27,15 @@ func TestClientSampleConfig(t *testing.T) {
 	assert.Pointer(pointConfig.InboundConfig).IsNotNil()
 	assert.Pointer(pointConfig.OutboundConfig).IsNotNil()
 
-	assert.StringLiteral(pointConfig.InboundConfig.Protocol).Equals("socks")
+	assert.String(pointConfig.InboundConfig.Protocol).Equals("socks")
 	assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()
 
-	assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("vmess")
+	assert.String(pointConfig.OutboundConfig.Protocol).Equals("vmess")
 	assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
 }
 
 func TestServerSampleConfig(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	GOPATH := os.Getenv("GOPATH")
 	baseDir := filepath.Join(GOPATH, "src", "github.com", "v2ray", "v2ray-core", "release", "config")
@@ -48,15 +47,15 @@ func TestServerSampleConfig(t *testing.T) {
 	assert.Pointer(pointConfig.InboundConfig).IsNotNil()
 	assert.Pointer(pointConfig.OutboundConfig).IsNotNil()
 
-	assert.StringLiteral(pointConfig.InboundConfig.Protocol).Equals("vmess")
+	assert.String(pointConfig.InboundConfig.Protocol).Equals("vmess")
 	assert.Pointer(pointConfig.InboundConfig.Settings).IsNotNil()
 
-	assert.StringLiteral(pointConfig.OutboundConfig.Protocol).Equals("freedom")
+	assert.String(pointConfig.OutboundConfig.Protocol).Equals("freedom")
 	assert.Pointer(pointConfig.OutboundConfig.Settings).IsNotNil()
 }
 
 func TestDefaultValueOfRandomAllocation(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rawJson := `{
     "protocol": "vmess",
@@ -70,7 +69,7 @@ func TestDefaultValueOfRandomAllocation(t *testing.T) {
 	inboundDetourConfig := new(InboundDetourConfig)
 	err := json.Unmarshal([]byte(rawJson), inboundDetourConfig)
 	assert.Error(err).IsNil()
-	assert.StringLiteral(inboundDetourConfig.Allocation.Strategy).Equals(AllocationStrategyRandom)
+	assert.String(inboundDetourConfig.Allocation.Strategy).Equals(AllocationStrategyRandom)
 	assert.Int(inboundDetourConfig.Allocation.Concurrency).Equals(3)
 	assert.Int(inboundDetourConfig.Allocation.Refresh).Equals(5)
 }

+ 31 - 17
testing/assert/address.go

@@ -2,11 +2,16 @@ package assert
 
 import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
-func Address(value v2net.Address) *AddressSubject {
-	return &AddressSubject{value: value}
+func (this *Assert) Address(value v2net.Address) *AddressSubject {
+	return &AddressSubject{
+		Subject: Subject{
+			disp: value.String(),
+			a:    this,
+		},
+		value: value,
+	}
 }
 
 type AddressSubject struct {
@@ -14,53 +19,62 @@ type AddressSubject struct {
 	value v2net.Address
 }
 
-func (subject *AddressSubject) Named(name string) *AddressSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *AddressSubject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.String())
+func (subject *AddressSubject) NotEquals(another v2net.Address) {
+	if subject.value.Equals(another) {
+		subject.Fail("not equals to", another.String())
+	}
 }
 
 func (subject *AddressSubject) Equals(another v2net.Address) {
 	if !subject.value.Equals(another) {
-		subject.Fail(subject.DisplayString(), "equals to", another)
+		subject.Fail("equals to", another.String())
+	}
+}
+
+func (subject *AddressSubject) NotEqualsString(another string) {
+	if subject.value.String() == another {
+		subject.Fail("not equals to string", another)
+	}
+}
+
+func (subject *AddressSubject) EqualsString(another string) {
+	if subject.value.String() != another {
+		subject.Fail("equals to string", another)
 	}
 }
 
 func (subject *AddressSubject) IsIPv4() {
 	if !subject.value.IsIPv4() {
-		subject.Fail(subject.DisplayString(), "is", serial.StringT("an IPv4 address"))
+		subject.Fail("is", "an IPv4 address")
 	}
 }
 
 func (subject *AddressSubject) IsNotIPv4() {
 	if subject.value.IsIPv4() {
-		subject.Fail(subject.DisplayString(), "is not", serial.StringT("an IPv4 address"))
+		subject.Fail("is not", "an IPv4 address")
 	}
 }
 
 func (subject *AddressSubject) IsIPv6() {
 	if !subject.value.IsIPv6() {
-		subject.Fail(subject.DisplayString(), "is", serial.StringT("an IPv6 address"))
+		subject.Fail("is", "an IPv6 address")
 	}
 }
 
 func (subject *AddressSubject) IsNotIPv6() {
 	if subject.value.IsIPv6() {
-		subject.Fail(subject.DisplayString(), "is not", serial.StringT("an IPv6 address"))
+		subject.Fail("is not", "an IPv6 address")
 	}
 }
 
 func (subject *AddressSubject) IsDomain() {
 	if !subject.value.IsDomain() {
-		subject.Fail(subject.DisplayString(), "is", serial.StringT("a domain address"))
+		subject.Fail("is", "a domain address")
 	}
 }
 
 func (subject *AddressSubject) IsNotDomain() {
 	if subject.value.IsDomain() {
-		subject.Fail(subject.DisplayString(), "is not", serial.StringT("a domain address"))
+		subject.Fail("is not", "a domain address")
 	}
 }

+ 13 - 9
testing/global.go → testing/assert/assert.go

@@ -1,4 +1,4 @@
-package unit
+package assert
 
 import (
 	"bytes"
@@ -8,10 +8,19 @@ import (
 	"testing"
 )
 
-var tGlobal *testing.T
+func On(t *testing.T) *Assert {
+	return &Assert{
+		t: t,
+	}
+}
+
+type Assert struct {
+	t *testing.T
+}
 
-func Current(t *testing.T) {
-	tGlobal = t
+func (this *Assert) Fail(message string) {
+	fmt.Println(decorate(message))
+	this.t.Fail()
 }
 
 func getCaller() (string, int) {
@@ -59,8 +68,3 @@ func decorate(s string) string {
 	buf.WriteByte('\n')
 	return buf.String()
 }
-
-func Fail(message string) {
-	fmt.Println(decorate(message))
-	tGlobal.Fail()
-}

+ 42 - 0
testing/assert/bool.go

@@ -0,0 +1,42 @@
+package assert
+
+import (
+	"strconv"
+)
+
+// Assert on a boolean variable.
+func (this *Assert) Bool(value bool) *BoolSubject {
+	return &BoolSubject{
+		Subject: Subject{
+			disp: strconv.FormatBool(value),
+			a:    this,
+		},
+		value: value,
+	}
+}
+
+type BoolSubject struct {
+	Subject
+	value bool
+}
+
+// to be equal to another boolean variable.
+func (subject *BoolSubject) Equals(expectation bool) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", strconv.FormatBool(expectation))
+	}
+}
+
+// to be true.
+func (subject *BoolSubject) IsTrue() {
+	if subject.value != true {
+		subject.Fail("is", "True")
+	}
+}
+
+// to be false.
+func (subject *BoolSubject) IsFalse() {
+	if subject.value != false {
+		subject.Fail("is", "False")
+	}
+}

+ 0 - 49
testing/assert/boolsubject.go

@@ -1,49 +0,0 @@
-package assert
-
-import (
-	"strconv"
-)
-
-// Assert on a boolean variable.
-func Bool(value bool) *BoolSubject {
-	return &BoolSubject{value: value}
-}
-
-type BoolSubject struct {
-	Subject
-	value bool
-}
-
-func (subject *BoolSubject) Named(name string) *BoolSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *BoolSubject) Fail(verb string, other bool) {
-	subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.FormatBool(other) + ">.")
-}
-
-func (subject *BoolSubject) DisplayString() string {
-	return subject.Subject.DisplayString(strconv.FormatBool(subject.value))
-}
-
-// to be equal to another boolean variable.
-func (subject *BoolSubject) Equals(expectation bool) {
-	if subject.value != expectation {
-		subject.Fail("is equal to", expectation)
-	}
-}
-
-// to be true.
-func (subject *BoolSubject) IsTrue() {
-	if subject.value != true {
-		subject.Fail("is", true)
-	}
-}
-
-// to be false.
-func (subject *BoolSubject) IsFalse() {
-	if subject.value != false {
-		subject.Fail("is", false)
-	}
-}

+ 38 - 0
testing/assert/byte.go

@@ -0,0 +1,38 @@
+package assert
+
+import (
+	"github.com/v2ray/v2ray-core/common/serial"
+)
+
+func (this *Assert) Byte(value byte) *ByteSubject {
+	return &ByteSubject{
+		Subject: Subject{
+			disp: serial.ByteToHexString(value),
+			a:    this,
+		},
+		value: value,
+	}
+}
+
+type ByteSubject struct {
+	Subject
+	value byte
+}
+
+func (subject *ByteSubject) Equals(expectation byte) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", serial.ByteToHexString(expectation))
+	}
+}
+
+func (subject *ByteSubject) GreaterThan(expectation byte) {
+	if subject.value <= expectation {
+		subject.Fail("is greater than", serial.ByteToHexString(expectation))
+	}
+}
+
+func (subject *ByteSubject) LessThan(expectation byte) {
+	if subject.value >= expectation {
+		subject.Fail("is less than", serial.ByteToHexString(expectation))
+	}
+}

+ 34 - 0
testing/assert/bytes.go

@@ -0,0 +1,34 @@
+package assert
+
+import (
+	"bytes"
+
+	"github.com/v2ray/v2ray-core/common/serial"
+)
+
+func (this *Assert) Bytes(value []byte) *BytesSubject {
+	return &BytesSubject{
+		Subject: Subject{
+			disp: serial.BytesToHexString(value),
+			a:    this,
+		},
+		value: value,
+	}
+}
+
+type BytesSubject struct {
+	Subject
+	value []byte
+}
+
+func (subject *BytesSubject) Equals(expectation []byte) {
+	if !bytes.Equal(subject.value, expectation) {
+		subject.Fail("is equal to", serial.BytesToHexString(expectation))
+	}
+}
+
+func (subject *BytesSubject) NotEquals(expectation []byte) {
+	if bytes.Equal(subject.value, expectation) {
+		subject.Fail("is not equal to", serial.BytesToHexString(expectation))
+	}
+}

+ 0 - 41
testing/assert/bytessubject.go

@@ -1,41 +0,0 @@
-package assert
-
-import (
-	"bytes"
-	"fmt"
-)
-
-func Bytes(value []byte) *BytesSubject {
-	return &BytesSubject{value: value}
-}
-
-type BytesSubject struct {
-	Subject
-	value []byte
-}
-
-func (subject *BytesSubject) Named(name string) *BytesSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *BytesSubject) Fail(verb string, other []byte) {
-	otherString := fmt.Sprintf("%v", other)
-	subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + otherString + ">.")
-}
-
-func (subject *BytesSubject) DisplayString() string {
-	return subject.Subject.DisplayString(fmt.Sprintf("%v", subject.value))
-}
-
-func (subject *BytesSubject) Equals(expectation []byte) {
-	if !bytes.Equal(subject.value, expectation) {
-		subject.Fail("is equal to", expectation)
-	}
-}
-
-func (subject *BytesSubject) NotEquals(expectation []byte) {
-	if bytes.Equal(subject.value, expectation) {
-		subject.Fail("is not equal to", expectation)
-	}
-}

+ 0 - 45
testing/assert/bytesubject.go

@@ -1,45 +0,0 @@
-package assert
-
-import (
-	"strconv"
-)
-
-func Byte(value byte) *ByteSubject {
-	return &ByteSubject{value: value}
-}
-
-type ByteSubject struct {
-	Subject
-	value byte
-}
-
-func (subject *ByteSubject) Named(name string) *ByteSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *ByteSubject) Fail(verb string, other byte) {
-	subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.Itoa(int(other)) + ">.")
-}
-
-func (subject *ByteSubject) DisplayString() string {
-	return subject.Subject.DisplayString(strconv.Itoa(int(subject.value)))
-}
-
-func (subject *ByteSubject) Equals(expectation byte) {
-	if subject.value != expectation {
-		subject.Fail("is equal to", expectation)
-	}
-}
-
-func (subject *ByteSubject) GreaterThan(expectation byte) {
-	if subject.value <= expectation {
-		subject.Fail("is greater than", expectation)
-	}
-}
-
-func (subject *ByteSubject) LessThan(expectation byte) {
-	if subject.value >= expectation {
-		subject.Fail("is less than", expectation)
-	}
-}

+ 26 - 16
testing/assert/destination.go

@@ -2,11 +2,16 @@ package assert
 
 import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
-func Destination(value v2net.Destination) *DestinationSubject {
-	return &DestinationSubject{value: value}
+func (this *Assert) Destination(value v2net.Destination) *DestinationSubject {
+	return &DestinationSubject{
+		Subject: Subject{
+			disp: value.String(),
+			a:    this,
+		},
+		value: value,
+	}
 }
 
 type DestinationSubject struct {
@@ -14,35 +19,40 @@ type DestinationSubject struct {
 	value v2net.Destination
 }
 
-func (this *DestinationSubject) Named(name string) *DestinationSubject {
-	this.Subject.Named(name)
-	return this
-}
-
-func (this *DestinationSubject) DisplayString() string {
-	return this.Subject.DisplayString(this.value.String())
-}
-
 func (this *DestinationSubject) IsTCP() {
 	if !this.value.IsTCP() {
-		this.Fail(this.DisplayString(), "is", serial.StringT("a TCP destination"))
+		this.Fail("is", "a TCP destination")
 	}
 }
 
 func (this *DestinationSubject) IsNotTCP() {
 	if this.value.IsTCP() {
-		this.Fail(this.DisplayString(), "is not", serial.StringT("a TCP destination"))
+		this.Fail("is not", "a TCP destination")
 	}
 }
 
 func (this *DestinationSubject) IsUDP() {
 	if !this.value.IsUDP() {
-		this.Fail(this.DisplayString(), "is", serial.StringT("a UDP destination"))
+		this.Fail("is", "a UDP destination")
 	}
 }
 
 func (this *DestinationSubject) IsNotUDP() {
 	if this.value.IsUDP() {
-		this.Fail(this.DisplayString(), "is not", serial.StringT("a UDP destination"))
+		this.Fail("is not", "a UDP destination")
+	}
+}
+
+func (this *DestinationSubject) EqualsString(another string) {
+	if this.value.String() != another {
+		this.Fail("not equals to string", another)
 	}
 }
+
+func (this *DestinationSubject) HasAddress() *AddressSubject {
+	return this.a.Address(this.value.Address())
+}
+
+func (this *DestinationSubject) HasPort() *PortSubject {
+	return this.a.Port(this.value.Port())
+}

+ 38 - 0
testing/assert/error.go

@@ -0,0 +1,38 @@
+package assert
+
+func (this *Assert) Error(value error) *ErrorSubject {
+	valueStr := ""
+	if value != nil {
+		valueStr = value.Error()
+	}
+	return &ErrorSubject{
+		Subject: Subject{
+			a:    this,
+			disp: valueStr,
+		},
+		value: value,
+	}
+}
+
+type ErrorSubject struct {
+	Subject
+	value error
+}
+
+func (subject *ErrorSubject) Equals(expectation error) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", expectation.Error())
+	}
+}
+
+func (subject *ErrorSubject) IsNil() {
+	if subject.value != nil {
+		subject.Fail("is", "nil")
+	}
+}
+
+func (subject *ErrorSubject) IsNotNil() {
+	if subject.value == nil {
+		subject.Fail("is not", "nil")
+	}
+}

+ 0 - 41
testing/assert/errorsubject.go

@@ -1,41 +0,0 @@
-package assert
-
-func Error(value error) *ErrorSubject {
-	return &ErrorSubject{value: value}
-}
-
-type ErrorSubject struct {
-	Subject
-	value error
-}
-
-func (subject *ErrorSubject) Named(name string) *ErrorSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *ErrorSubject) Fail(verb string, other error) {
-	subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + other.Error() + ">.")
-}
-
-func (subject *ErrorSubject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.Error())
-}
-
-func (subject *ErrorSubject) Equals(expectation error) {
-	if subject.value != expectation {
-		subject.Fail("is equal to", expectation)
-	}
-}
-
-func (subject *ErrorSubject) IsNil() {
-	if subject.value != nil {
-		subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
-	}
-}
-
-func (subject *ErrorSubject) IsNotNil() {
-	if subject.value == nil {
-		subject.FailWithMessage("Not true that the error is not nil.")
-	}
-}

+ 44 - 0
testing/assert/int64.go

@@ -0,0 +1,44 @@
+package assert
+
+import (
+	"github.com/v2ray/v2ray-core/common/serial"
+)
+
+func (this *Assert) Int64(value int64) *Int64Subject {
+	return &Int64Subject{
+		Subject: Subject{
+			a:    this,
+			disp: serial.Int64ToString(value),
+		},
+		value: value,
+	}
+}
+
+type Int64Subject struct {
+	Subject
+	value int64
+}
+
+func (subject *Int64Subject) Equals(expectation int64) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", serial.Int64ToString(expectation))
+	}
+}
+
+func (subject *Int64Subject) GreaterThan(expectation int64) {
+	if subject.value <= expectation {
+		subject.Fail("is greater than", serial.Int64ToString(expectation))
+	}
+}
+
+func (subject *Int64Subject) AtMost(expectation int64) {
+	if subject.value > expectation {
+		subject.Fail("is at most", serial.Int64ToString(expectation))
+	}
+}
+
+func (subject *Int64Subject) AtLeast(expectation int64) {
+	if subject.value < expectation {
+		subject.Fail("is at least", serial.Int64ToString(expectation))
+	}
+}

+ 0 - 51
testing/assert/int64subject.go

@@ -1,51 +0,0 @@
-package assert
-
-import (
-	"strconv"
-)
-
-func Int64(value int64) *Int64Subject {
-	return &Int64Subject{value: value}
-}
-
-type Int64Subject struct {
-	Subject
-	value int64
-}
-
-func (subject *Int64Subject) Named(name string) *Int64Subject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *Int64Subject) Fail(verb string, other int64) {
-	subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + strconv.FormatInt(other, 10) + ">.")
-}
-
-func (subject *Int64Subject) DisplayString() string {
-	return subject.Subject.DisplayString(strconv.FormatInt(subject.value, 10))
-}
-
-func (subject *Int64Subject) Equals(expectation int64) {
-	if subject.value != expectation {
-		subject.Fail("is equal to", expectation)
-	}
-}
-
-func (subject *Int64Subject) GreaterThan(expectation int64) {
-	if subject.value <= expectation {
-		subject.Fail("is greater than", expectation)
-	}
-}
-
-func (subject *Int64Subject) AtMost(expectation int64) {
-	if subject.value > expectation {
-		subject.Fail("is at most", expectation)
-	}
-}
-
-func (subject *Int64Subject) AtLeast(expectation int64) {
-	if subject.value < expectation {
-		subject.Fail("is at least", expectation)
-	}
-}

+ 15 - 18
testing/assert/intsubject.go

@@ -4,38 +4,35 @@ import (
 	"github.com/v2ray/v2ray-core/common/serial"
 )
 
-func Int(value int) *IntSubject {
-	return &IntSubject{value: serial.IntLiteral(value)}
+func (this *Assert) Int(value int) *IntSubject {
+	return &IntSubject{
+		Subject: Subject{
+			a:    this,
+			disp: serial.IntToString(value),
+		},
+		value: value,
+	}
 }
 
 type IntSubject struct {
 	Subject
-	value serial.IntLiteral
-}
-
-func (subject *IntSubject) Named(name string) *IntSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *IntSubject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.String())
+	value int
 }
 
 func (subject *IntSubject) Equals(expectation int) {
-	if subject.value.Value() != expectation {
-		subject.Fail(subject.DisplayString(), "is equal to", serial.IntLiteral(expectation))
+	if subject.value != expectation {
+		subject.Fail("is equal to", serial.IntToString(expectation))
 	}
 }
 
 func (subject *IntSubject) GreaterThan(expectation int) {
-	if subject.value.Value() <= expectation {
-		subject.Fail(subject.DisplayString(), "is greater than", serial.IntLiteral(expectation))
+	if subject.value <= expectation {
+		subject.Fail("is greater than", serial.IntToString(expectation))
 	}
 }
 
 func (subject *IntSubject) LessThan(expectation int) {
-	if subject.value.Value() >= expectation {
-		subject.Fail(subject.DisplayString(), "is less than", serial.IntLiteral(expectation))
+	if subject.value >= expectation {
+		subject.Fail("is less than", serial.IntToString(expectation))
 	}
 }

+ 10 - 15
testing/assert/ip.go

@@ -3,12 +3,16 @@ package assert
 import (
 	"bytes"
 	"net"
-
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
-func IP(value net.IP) *IPSubject {
-	return &IPSubject{value: value}
+func (this *Assert) IP(value net.IP) *IPSubject {
+	return &IPSubject{
+		Subject: Subject{
+			a:    this,
+			disp: value.String(),
+		},
+		value: value,
+	}
 }
 
 type IPSubject struct {
@@ -16,23 +20,14 @@ type IPSubject struct {
 	value net.IP
 }
 
-func (subject *IPSubject) Named(name string) *IPSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *IPSubject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.String())
-}
-
 func (subject *IPSubject) IsNil() {
 	if subject.value != nil {
-		subject.Fail(subject.DisplayString(), "is", serial.StringT("nil"))
+		subject.Fail("is", "nil")
 	}
 }
 
 func (subject *IPSubject) Equals(ip net.IP) {
 	if !bytes.Equal([]byte(subject.value), []byte(ip)) {
-		subject.Fail(subject.DisplayString(), "equals to", ip)
+		subject.Fail("equals to", ip.String())
 	}
 }

+ 38 - 0
testing/assert/pointer.go

@@ -0,0 +1,38 @@
+package assert
+
+import (
+	"github.com/v2ray/v2ray-core/common/serial"
+)
+
+func (this *Assert) Pointer(value interface{}) *PointerSubject {
+	return &PointerSubject{
+		Subject: Subject{
+			a:    this,
+			disp: serial.PointerToString(value),
+		},
+		value: value,
+	}
+}
+
+type PointerSubject struct {
+	Subject
+	value interface{}
+}
+
+func (subject *PointerSubject) Equals(expectation interface{}) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", serial.PointerToString(expectation))
+	}
+}
+
+func (subject *PointerSubject) IsNil() {
+	if subject.value != nil {
+		subject.Fail("is", "nil")
+	}
+}
+
+func (subject *PointerSubject) IsNotNil() {
+	if subject.value == nil {
+		subject.Fail("is not", "nil")
+	}
+}

+ 0 - 45
testing/assert/pointersubject.go

@@ -1,45 +0,0 @@
-package assert
-
-import (
-	"fmt"
-)
-
-func Pointer(value interface{}) *PointerSubject {
-	return &PointerSubject{value: value}
-}
-
-type PointerSubject struct {
-	Subject
-	value interface{}
-}
-
-func (subject *PointerSubject) Named(name string) *PointerSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *PointerSubject) Fail(verb string, other interface{}) {
-	subject.FailWithMessage(fmt.Sprintf("Not true that %s %s <%v>.", subject.DisplayString(), verb, other))
-}
-
-func (subject *PointerSubject) DisplayString() string {
-	return subject.Subject.DisplayString(fmt.Sprintf("%v", subject.value))
-}
-
-func (subject *PointerSubject) Equals(expectation interface{}) {
-	if subject.value != expectation {
-		subject.Fail("is equal to", expectation)
-	}
-}
-
-func (subject *PointerSubject) IsNil() {
-	if subject.value != nil {
-		subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
-	}
-}
-
-func (subject *PointerSubject) IsNotNil() {
-	if subject.value == nil {
-		subject.FailWithMessage("Not true that " + subject.DisplayString() + " is not nil.")
-	}
-}

+ 12 - 16
testing/assert/port.go

@@ -2,11 +2,16 @@ package assert
 
 import (
 	v2net "github.com/v2ray/v2ray-core/common/net"
-	"github.com/v2ray/v2ray-core/common/serial"
 )
 
-func Port(value v2net.Port) *PortSubject {
-	return &PortSubject{value: value}
+func (this *Assert) Port(value v2net.Port) *PortSubject {
+	return &PortSubject{
+		Subject: Subject{
+			a:    this,
+			disp: value.String(),
+		},
+		value: value,
+	}
 }
 
 type PortSubject struct {
@@ -14,35 +19,26 @@ type PortSubject struct {
 	value v2net.Port
 }
 
-func (subject *PortSubject) Named(name string) *PortSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *PortSubject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.String())
-}
-
 func (subject *PortSubject) Equals(expectation v2net.Port) {
 	if subject.value.Value() != expectation.Value() {
-		subject.Fail(subject.DisplayString(), "is equal to", expectation)
+		subject.Fail("is equal to", expectation.String())
 	}
 }
 
 func (subject *PortSubject) GreaterThan(expectation v2net.Port) {
 	if subject.value.Value() <= expectation.Value() {
-		subject.Fail(subject.DisplayString(), "is greater than", expectation)
+		subject.Fail("is greater than", expectation.String())
 	}
 }
 
 func (subject *PortSubject) LessThan(expectation v2net.Port) {
 	if subject.value.Value() >= expectation.Value() {
-		subject.Fail(subject.DisplayString(), "is less than", expectation)
+		subject.Fail("is less than", expectation.String())
 	}
 }
 
 func (subject *PortSubject) IsValid() {
 	if subject.value == 0 {
-		subject.Fail(subject.DisplayString(), "is", serial.StringT("a valid port"))
+		subject.Fail("is", "a valid port")
 	}
 }

+ 44 - 0
testing/assert/string.go

@@ -0,0 +1,44 @@
+package assert
+
+import (
+	"strings"
+)
+
+func (this *Assert) String(value string) *StringSubject {
+	return &StringSubject{
+		Subject: Subject{
+			a:    this,
+			disp: value,
+		},
+		value: value,
+	}
+}
+
+type StringSubject struct {
+	Subject
+	value string
+}
+
+func (subject *StringSubject) Equals(expectation string) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", expectation)
+	}
+}
+
+func (subject *StringSubject) NotEquals(expectation string) {
+	if subject.value == expectation {
+		subject.Fail("is not equal to ", expectation)
+	}
+}
+
+func (subject *StringSubject) Contains(substring string) {
+	if !strings.Contains(subject.value, substring) {
+		subject.Fail("contains", substring)
+	}
+}
+
+func (subject *StringSubject) NotContains(substring string) {
+	if strings.Contains(subject.value, substring) {
+		subject.Fail("doesn't contain", substring)
+	}
+}

+ 0 - 53
testing/assert/stringsubject.go

@@ -1,53 +0,0 @@
-package assert
-
-import (
-	"strings"
-
-	"github.com/v2ray/v2ray-core/common/serial"
-)
-
-func StringLiteral(value string) *StringSubject {
-	return String(serial.StringT((value)))
-}
-
-func String(value serial.String) *StringSubject {
-	return &StringSubject{value: value}
-}
-
-type StringSubject struct {
-	Subject
-	value serial.String
-}
-
-func (subject *StringSubject) Named(name string) *StringSubject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *StringSubject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.String())
-}
-
-func (subject *StringSubject) Equals(expectation string) {
-	if subject.value.String() != expectation {
-		subject.Fail(subject.DisplayString(), "is equal to", serial.StringT(expectation))
-	}
-}
-
-func (subject *StringSubject) NotEquals(expectation string) {
-	if subject.value.String() == expectation {
-		subject.Fail(subject.DisplayString(), "is not equal to ", serial.StringT(expectation))
-	}
-}
-
-func (subject *StringSubject) Contains(substring serial.String) {
-	if !strings.Contains(subject.value.String(), substring.String()) {
-		subject.Fail(subject.DisplayString(), "contains", substring)
-	}
-}
-
-func (subject *StringSubject) NotContains(substring serial.String) {
-	if strings.Contains(subject.value.String(), substring.String()) {
-		subject.Fail(subject.DisplayString(), "doesn't contain", substring)
-	}
-}

+ 8 - 24
testing/assert/subject.go

@@ -1,38 +1,22 @@
 package assert
 
-import (
-	"github.com/v2ray/v2ray-core/common/serial"
-	v2testing "github.com/v2ray/v2ray-core/testing"
-)
-
 type Subject struct {
-	name string
-}
-
-func NewSubject() *Subject {
-	return &Subject{
-		name: "",
-	}
+	disp string
+	a    *Assert
 }
 
-func (subject *Subject) Fail(displayString string, verb string, other serial.String) {
-	subject.FailWithMessage("Not true that " + displayString + " " + verb + " <" + other.String() + ">.")
+func (subject *Subject) Fail(verb string, other string) {
+	subject.FailWithMessage("Not true that " + subject.DisplayString() + " " + verb + " <" + other + ">.")
 }
 
 func (subject *Subject) FailWithMessage(message string) {
-	v2testing.Fail(message)
+	subject.a.Fail(message)
 }
 
-func (subject *Subject) Named(name string) {
-	subject.name = name
-}
-
-func (subject *Subject) DisplayString(value string) string {
+func (subject *Subject) DisplayString() string {
+	value := subject.disp
 	if len(value) == 0 {
 		value = "unknown"
 	}
-	if len(subject.name) == 0 {
-		return "<" + value + ">"
-	}
-	return subject.name + "(<" + value + ">)"
+	return "<" + value + ">"
 }

+ 50 - 0
testing/assert/uint16.go

@@ -0,0 +1,50 @@
+package assert
+
+import (
+	"github.com/v2ray/v2ray-core/common/serial"
+)
+
+func (this *Assert) Uint16(value uint16) *Uint16Subject {
+	return &Uint16Subject{
+		Subject: Subject{
+			a:    this,
+			disp: serial.Uint16ToString(value),
+		},
+		value: value,
+	}
+}
+
+type Uint16Subject struct {
+	Subject
+	value uint16
+}
+
+func (subject *Uint16Subject) Equals(expectation uint16) {
+	if subject.value != expectation {
+		subject.Fail("is equal to", serial.Uint16ToString(expectation))
+	}
+}
+
+func (subject *Uint16Subject) GreaterThan(expectation uint16) {
+	if subject.value <= expectation {
+		subject.Fail("is greater than", serial.Uint16ToString(expectation))
+	}
+}
+
+func (subject *Uint16Subject) LessThan(expectation uint16) {
+	if subject.value >= expectation {
+		subject.Fail("is less than", serial.Uint16ToString(expectation))
+	}
+}
+
+func (subject *Uint16Subject) IsPositive() {
+	if subject.value <= 0 {
+		subject.Fail("is", "positive")
+	}
+}
+
+func (subject *Uint16Subject) IsNegative() {
+	if subject.value >= 0 {
+		subject.Fail("is not", "negative")
+	}
+}

+ 0 - 47
testing/assert/uint16subject.go

@@ -1,47 +0,0 @@
-package assert
-
-import (
-	"github.com/v2ray/v2ray-core/common/serial"
-)
-
-func Uint16(value uint16) *Uint16Subject {
-	return &Uint16Subject{value: serial.Uint16Literal(value)}
-}
-
-type Uint16Subject struct {
-	Subject
-	value serial.Uint16Literal
-}
-
-func (subject *Uint16Subject) Named(name string) *Uint16Subject {
-	subject.Subject.Named(name)
-	return subject
-}
-
-func (subject *Uint16Subject) DisplayString() string {
-	return subject.Subject.DisplayString(subject.value.String())
-}
-
-func (subject *Uint16Subject) Equals(expectation uint16) {
-	if subject.value.Value() != expectation {
-		subject.Fail(subject.DisplayString(), "is equal to", serial.Uint16Literal(expectation))
-	}
-}
-
-func (subject *Uint16Subject) GreaterThan(expectation uint16) {
-	if subject.value.Value() <= expectation {
-		subject.Fail(subject.DisplayString(), "is greater than", serial.Uint16Literal(expectation))
-	}
-}
-
-func (subject *Uint16Subject) LessThan(expectation uint16) {
-	if subject.value.Value() >= expectation {
-		subject.Fail(subject.DisplayString(), "is less than", serial.Uint16Literal(expectation))
-	}
-}
-
-func (subject *Uint16Subject) Positive() {
-	if subject.value.Value() <= 0 {
-		subject.FailWithMessage("Not true that " + subject.DisplayString() + " is positive.")
-	}
-}

+ 2 - 3
testing/scenarios/dokodemo_test.go

@@ -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()
 	}
 

+ 2 - 3
testing/scenarios/dynamic_vmess_test.go

@@ -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()
 	}

+ 2 - 3
testing/scenarios/http_test.go

@@ -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()
 }

+ 2 - 3
testing/scenarios/router_test.go

@@ -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{

+ 4 - 5
testing/scenarios/shadowsocks_test.go

@@ -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()

+ 4 - 5
testing/scenarios/socks_end_test.go

@@ -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{

+ 1 - 2
tools/build/build_test.go

@@ -6,7 +6,6 @@ import (
 	"path/filepath"
 	"testing"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
@@ -32,7 +31,7 @@ func allFilesExists(files ...string) bool {
 }
 
 func TestBuildMacOS(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 	binPath = filepath.Join(os.Getenv("GOPATH"), "testing")
 	cleanBinPath()
 

+ 2 - 3
tools/build/env_test.go

@@ -3,12 +3,11 @@ package main
 import (
 	"testing"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestParseOS(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	assert.Pointer(parseOS("windows")).Equals(Windows)
 	assert.Pointer(parseOS("macos")).Equals(MacOS)
@@ -17,7 +16,7 @@ func TestParseOS(t *testing.T) {
 }
 
 func TestParseArch(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	assert.Pointer(parseArch("x86")).Equals(X86)
 	assert.Pointer(parseArch("x64")).Equals(Amd64)

+ 2 - 3
tools/build/go_test.go

@@ -10,12 +10,11 @@ import (
 	"testing"
 	"time"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestBuildAndRun(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	gopath := os.Getenv("GOPATH")
 	goOS := parseOS(runtime.GOOS)
@@ -42,7 +41,7 @@ func TestBuildAndRun(t *testing.T) {
 	errStr := string(errBuffer.Bytes())
 
 	assert.Bool(strings.Contains(outStr, "v1.0")).IsTrue()
-	assert.StringLiteral(errStr).Equals("")
+	assert.String(errStr).Equals("")
 
 	os.Remove(target)
 }

+ 2 - 3
tools/git/git_test.go

@@ -3,12 +3,11 @@ package git
 import (
 	"testing"
 
-	v2testing "github.com/v2ray/v2ray-core/testing"
 	"github.com/v2ray/v2ray-core/testing/assert"
 )
 
 func TestRevParse(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	rev, err := RevParse("HEAD")
 	assert.Error(err).IsNil()
@@ -16,7 +15,7 @@ func TestRevParse(t *testing.T) {
 }
 
 func TestRepoVersion(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	version, err := RepoVersionHead()
 	assert.Error(err).IsNil()

+ 2 - 3
transport/dialer/dialer_test.go

@@ -5,14 +5,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/transport/dialer"
 )
 
 func TestDialDomain(t *testing.T) {
-	v2testing.Current(t)
+	assert := assert.On(t)
 
 	server := &tcp.Server{
 		Port: v2nettesting.PickPort(),
@@ -23,6 +22,6 @@ func TestDialDomain(t *testing.T) {
 
 	conn, err := Dial(v2net.TCPDestination(v2net.DomainAddress("local.v2ray.com"), dest.Port()))
 	assert.Error(err).IsNil()
-	assert.StringLiteral(conn.RemoteAddr().String()).Equals("127.0.0.1:" + dest.Port().String())
+	assert.String(conn.RemoteAddr().String()).Equals("127.0.0.1:" + dest.Port().String())
 	conn.Close()
 }