1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 10:08:15 -05:00
v2fly/proxy/vmess/encoding/commands_test.go

41 lines
893 B
Go
Raw Normal View History

2016-07-23 07:17:51 -04:00
package encoding_test
2016-02-26 18:05:53 -05:00
import (
"testing"
2016-12-09 05:35:27 -05:00
"v2ray.com/core/common/buf"
2016-08-20 14:55:45 -04:00
"v2ray.com/core/common/protocol"
"v2ray.com/core/common/uuid"
. "v2ray.com/core/proxy/vmess/encoding"
2017-10-24 10:15:35 -04:00
. "v2ray.com/ext/assert"
2016-02-26 18:05:53 -05:00
)
func TestSwitchAccount(t *testing.T) {
2017-10-24 10:15:35 -04:00
assert := With(t)
2016-02-26 18:05:53 -05:00
sa := &protocol.CommandSwitchAccount{
Port: 1234,
ID: uuid.New(),
AlterIds: 1024,
Level: 128,
ValidMin: 16,
}
2016-12-09 06:08:25 -05:00
buffer := buf.New()
2016-02-26 18:05:53 -05:00
err := MarshalCommand(sa, buffer)
2017-10-24 10:15:35 -04:00
assert(err, IsNil)
2016-02-26 18:05:53 -05:00
2016-12-05 15:33:24 -05:00
cmd, err := UnmarshalCommand(1, buffer.BytesFrom(2))
2017-10-24 10:15:35 -04:00
assert(err, IsNil)
2016-02-26 18:05:53 -05:00
sa2, ok := cmd.(*protocol.CommandSwitchAccount)
2017-10-24 10:15:35 -04:00
assert(ok, IsTrue)
assert(sa.Host, IsNil)
assert(sa2.Host, IsNil)
assert(sa.Port, Equals, sa2.Port)
assert(sa.ID.String(), Equals, sa2.ID.String())
assert(sa.AlterIds, Equals, sa2.AlterIds)
assert(byte(sa.Level), Equals, byte(sa2.Level))
assert(sa.ValidMin, Equals, sa2.ValidMin)
2016-02-26 18:05:53 -05:00
}