mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-18 23:00:12 +00:00
simplify testing
This commit is contained in:
1 parent
3582b9d869
commit
fc63f0432c
99 files changed
+726
-817
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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()),
|
||||
|
||||
Reference in new issue
Block a user