v2ray-core/proxy/vmess/command/accounts_test.go

38 lines
927 B
Go
Raw Normal View History

2015-12-12 13:11:49 +01:00
package command_test
import (
"bytes"
"testing"
2016-01-19 01:21:07 +01:00
netassert "github.com/v2ray/v2ray-core/common/net/testing/assert"
2015-12-12 13:11:49 +01: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 23:41:40 +01:00
Port: 1234,
ID: uuid.New(),
AlterIds: 1024,
ValidSec: 8080,
2015-12-12 13:11:49 +01:00
}
cmd, err := CreateResponseCommand(1)
assert.Error(err).IsNil()
buffer := bytes.NewBuffer(make([]byte, 0, 1024))
2016-01-19 23:41:40 +01:00
sa.Marshal(buffer)
2015-12-12 13:11:49 +01:00
cmd.Unmarshal(buffer.Bytes())
sa2, ok := cmd.(*SwitchAccount)
assert.Bool(ok).IsTrue()
2016-01-19 01:21:07 +01:00
netassert.Port(sa.Port).Equals(sa2.Port)
2015-12-12 13:11:49 +01:00
assert.String(sa.ID).Equals(sa2.ID.String())
2016-01-19 01:21:07 +01:00
assert.Uint16(sa.AlterIds.Value()).Equals(sa2.AlterIds.Value())
2016-01-19 23:41:40 +01:00
assert.Uint16(sa.ValidSec.Value()).Equals(sa2.ValidSec.Value())
2015-12-12 13:11:49 +01:00
}