mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-02 09:17:55 -04:00
38 lines
731 B
Go
38 lines
731 B
Go
package encoding_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
"v2ray.com/core/common"
|
|
"v2ray.com/core/common/buf"
|
|
"v2ray.com/core/common/protocol"
|
|
"v2ray.com/core/common/uuid"
|
|
. "v2ray.com/core/proxy/vmess/encoding"
|
|
)
|
|
|
|
func TestSwitchAccount(t *testing.T) {
|
|
sa := &protocol.CommandSwitchAccount{
|
|
Port: 1234,
|
|
ID: uuid.New(),
|
|
AlterIds: 1024,
|
|
Level: 128,
|
|
ValidMin: 16,
|
|
}
|
|
|
|
buffer := buf.New()
|
|
common.Must(MarshalCommand(sa, buffer))
|
|
|
|
cmd, err := UnmarshalCommand(1, buffer.BytesFrom(2))
|
|
common.Must(err)
|
|
|
|
sa2, ok := cmd.(*protocol.CommandSwitchAccount)
|
|
if !ok {
|
|
t.Fatal("failed to convert command to CommandSwitchAccount")
|
|
}
|
|
if r := cmp.Diff(sa2, sa); r != "" {
|
|
t.Error(r)
|
|
}
|
|
}
|