1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-12 15:27:16 -05:00
v2fly/proxy/vmess/command/accounts_test.go

42 lines
1.0 KiB
Go
Raw Normal View History

2015-12-12 07:11:49 -05:00
package command_test
import (
"bytes"
"testing"
2016-01-18 19:21:07 -05:00
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
2015-12-12 07:11:49 -05:00
"github.com/v2ray/v2ray-core/common/uuid"
. "github.com/v2ray/v2ray-core/proxy/vmess/command"
v2testing "github.com/v2ray/v2ray-core/testing"
"github.com/v2ray/v2ray-core/testing/assert"
)
func TestSwitchAccount(t *testing.T) {
v2testing.Current(t)
sa := &SwitchAccount{
2016-01-19 17:41:40 -05:00
Port: 1234,
ID: uuid.New(),
AlterIds: 1024,
Level: 128,
ValidMin: 16,
2015-12-12 07:11:49 -05:00
}
cmd, err := CreateResponseCommand(1)
assert.Error(err).IsNil()
buffer := bytes.NewBuffer(make([]byte, 0, 1024))
2016-01-19 17:41:40 -05:00
sa.Marshal(buffer)
2015-12-12 07:11:49 -05:00
cmd.Unmarshal(buffer.Bytes())
sa2, ok := cmd.(*SwitchAccount)
assert.Bool(ok).IsTrue()
2016-01-21 11:29:18 -05:00
assert.Pointer(sa.Host).IsNil()
assert.Pointer(sa2.Host).IsNil()
2016-01-18 19:21:07 -05:00
netassert.Port(sa.Port).Equals(sa2.Port)
2015-12-12 07:11:49 -05:00
assert.String(sa.ID).Equals(sa2.ID.String())
2016-01-18 19:21:07 -05:00
assert.Uint16(sa.AlterIds.Value()).Equals(sa2.AlterIds.Value())
assert.Byte(byte(sa.Level)).Equals(byte(sa2.Level))
assert.Byte(sa.ValidMin).Equals(sa2.ValidMin)
2015-12-12 07:11:49 -05:00
}