2016-07-23 11:17:51 +00:00
|
|
|
package encoding_test
|
2016-02-26 23:05:53 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2019-01-31 19:57:01 +00:00
|
|
|
"github.com/google/go-cmp/cmp"
|
|
|
|
|
|
|
|
"v2ray.com/core/common"
|
2016-12-09 10:35:27 +00:00
|
|
|
"v2ray.com/core/common/buf"
|
2016-08-20 18:55:45 +00:00
|
|
|
"v2ray.com/core/common/protocol"
|
|
|
|
"v2ray.com/core/common/uuid"
|
|
|
|
. "v2ray.com/core/proxy/vmess/encoding"
|
2016-02-26 23:05:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSwitchAccount(t *testing.T) {
|
|
|
|
sa := &protocol.CommandSwitchAccount{
|
|
|
|
Port: 1234,
|
|
|
|
ID: uuid.New(),
|
|
|
|
AlterIds: 1024,
|
|
|
|
Level: 128,
|
|
|
|
ValidMin: 16,
|
|
|
|
}
|
|
|
|
|
2016-12-09 11:08:25 +00:00
|
|
|
buffer := buf.New()
|
2019-01-31 19:57:01 +00:00
|
|
|
common.Must(MarshalCommand(sa, buffer))
|
2016-02-26 23:05:53 +00:00
|
|
|
|
2016-12-05 20:33:24 +00:00
|
|
|
cmd, err := UnmarshalCommand(1, buffer.BytesFrom(2))
|
2019-01-31 19:57:01 +00:00
|
|
|
common.Must(err)
|
2016-02-26 23:05:53 +00:00
|
|
|
|
|
|
|
sa2, ok := cmd.(*protocol.CommandSwitchAccount)
|
2019-01-31 19:57:01 +00:00
|
|
|
if !ok {
|
|
|
|
t.Fatal("failed to convert command to CommandSwitchAccount")
|
|
|
|
}
|
|
|
|
if r := cmp.Diff(sa2, sa); r != "" {
|
|
|
|
t.Error(r)
|
|
|
|
}
|
2016-02-26 23:05:53 +00:00
|
|
|
}
|