mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.0 KiB
41 lines
1.0 KiB
8 years ago
|
package encoding_test
|
||
9 years ago
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
9 years ago
|
"github.com/v2ray/v2ray-core/common/alloc"
|
||
9 years ago
|
"github.com/v2ray/v2ray-core/common/protocol"
|
||
|
"github.com/v2ray/v2ray-core/common/uuid"
|
||
8 years ago
|
. "github.com/v2ray/v2ray-core/proxy/vmess/encoding"
|
||
9 years ago
|
"github.com/v2ray/v2ray-core/testing/assert"
|
||
|
)
|
||
|
|
||
|
func TestSwitchAccount(t *testing.T) {
|
||
9 years ago
|
assert := assert.On(t)
|
||
9 years ago
|
|
||
|
sa := &protocol.CommandSwitchAccount{
|
||
|
Port: 1234,
|
||
|
ID: uuid.New(),
|
||
|
AlterIds: 1024,
|
||
|
Level: 128,
|
||
|
ValidMin: 16,
|
||
|
}
|
||
|
|
||
9 years ago
|
buffer := alloc.NewBuffer().Clear()
|
||
9 years ago
|
err := MarshalCommand(sa, buffer)
|
||
|
assert.Error(err).IsNil()
|
||
|
|
||
9 years ago
|
cmd, err := UnmarshalCommand(1, buffer.Value[2:])
|
||
9 years ago
|
assert.Error(err).IsNil()
|
||
|
|
||
|
sa2, ok := cmd.(*protocol.CommandSwitchAccount)
|
||
|
assert.Bool(ok).IsTrue()
|
||
|
assert.Pointer(sa.Host).IsNil()
|
||
|
assert.Pointer(sa2.Host).IsNil()
|
||
9 years ago
|
assert.Port(sa.Port).Equals(sa2.Port)
|
||
9 years ago
|
assert.String(sa.ID.String()).Equals(sa2.ID.String())
|
||
|
assert.Uint16(sa.AlterIds).Equals(sa2.AlterIds)
|
||
9 years ago
|
assert.Byte(byte(sa.Level)).Equals(byte(sa2.Level))
|
||
|
assert.Byte(sa.ValidMin).Equals(sa2.ValidMin)
|
||
|
}
|