|
@@ -1,4 +1,4 @@
|
|
|
-package protocol
|
|
|
|
|
|
|
+package protocol_test
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"bytes"
|
|
"bytes"
|
|
@@ -10,17 +10,17 @@ import (
|
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
v2net "github.com/v2ray/v2ray-core/common/net"
|
|
|
"github.com/v2ray/v2ray-core/common/uuid"
|
|
"github.com/v2ray/v2ray-core/common/uuid"
|
|
|
"github.com/v2ray/v2ray-core/proxy/vmess"
|
|
"github.com/v2ray/v2ray-core/proxy/vmess"
|
|
|
- "github.com/v2ray/v2ray-core/proxy/vmess/protocol/user"
|
|
|
|
|
- "github.com/v2ray/v2ray-core/proxy/vmess/protocol/user/testing/mocks"
|
|
|
|
|
|
|
+ . "github.com/v2ray/v2ray-core/proxy/vmess/protocol"
|
|
|
|
|
+ protocoltesting "github.com/v2ray/v2ray-core/proxy/vmess/protocol/testing"
|
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
v2testing "github.com/v2ray/v2ray-core/testing"
|
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
|
"github.com/v2ray/v2ray-core/testing/assert"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
type FakeTimestampGenerator struct {
|
|
type FakeTimestampGenerator struct {
|
|
|
- timestamp user.Timestamp
|
|
|
|
|
|
|
+ timestamp Timestamp
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func (this *FakeTimestampGenerator) Next() user.Timestamp {
|
|
|
|
|
|
|
+func (this *FakeTimestampGenerator) Next() Timestamp {
|
|
|
return this.timestamp
|
|
return this.timestamp
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -57,7 +57,7 @@ func TestVMessSerialization(t *testing.T) {
|
|
|
id: userId,
|
|
id: userId,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- userSet := mocks.MockUserSet{[]vmess.User{}, make(map[string]int), make(map[string]user.Timestamp)}
|
|
|
|
|
|
|
+ userSet := protocoltesting.MockUserSet{[]vmess.User{}, make(map[string]int), make(map[string]Timestamp)}
|
|
|
userSet.AddUser(testUser)
|
|
userSet.AddUser(testUser)
|
|
|
|
|
|
|
|
request := new(VMessRequest)
|
|
request := new(VMessRequest)
|
|
@@ -75,7 +75,7 @@ func TestVMessSerialization(t *testing.T) {
|
|
|
request.Address = v2net.DomainAddress("v2ray.com")
|
|
request.Address = v2net.DomainAddress("v2ray.com")
|
|
|
request.Port = v2net.Port(80)
|
|
request.Port = v2net.Port(80)
|
|
|
|
|
|
|
|
- mockTime := user.Timestamp(1823730)
|
|
|
|
|
|
|
+ mockTime := Timestamp(1823730)
|
|
|
|
|
|
|
|
buffer, err := request.ToBytes(&FakeTimestampGenerator{timestamp: mockTime}, nil)
|
|
buffer, err := request.ToBytes(&FakeTimestampGenerator{timestamp: mockTime}, nil)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -113,7 +113,7 @@ func BenchmarkVMessRequestWriting(b *testing.B) {
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
userId := vmess.NewID(id)
|
|
userId := vmess.NewID(id)
|
|
|
- userSet := mocks.MockUserSet{[]vmess.User{}, make(map[string]int), make(map[string]user.Timestamp)}
|
|
|
|
|
|
|
+ userSet := protocoltesting.MockUserSet{[]vmess.User{}, make(map[string]int), make(map[string]Timestamp)}
|
|
|
|
|
|
|
|
testUser := &TestUser{
|
|
testUser := &TestUser{
|
|
|
id: userId,
|
|
id: userId,
|
|
@@ -135,6 +135,6 @@ func BenchmarkVMessRequestWriting(b *testing.B) {
|
|
|
request.Port = v2net.Port(80)
|
|
request.Port = v2net.Port(80)
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
for i := 0; i < b.N; i++ {
|
|
|
- request.ToBytes(user.NewRandomTimestampGenerator(user.Timestamp(time.Now().Unix()), 30), nil)
|
|
|
|
|
|
|
+ request.ToBytes(NewRandomTimestampGenerator(Timestamp(time.Now().Unix()), 30), nil)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|