1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-25 21:36:13 -04:00

fix test break

This commit is contained in:
Darien Raymond 2018-08-27 00:33:27 +02:00
parent 54e1bb96cc
commit 16051587b5
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 18 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import (
"testing"
"time"
"v2ray.com/core/common"
"v2ray.com/core/common/net"
. "v2ray.com/core/common/protocol"
"v2ray.com/core/common/uuid"
@ -39,19 +40,25 @@ func TestUserInServerSpec(t *testing.T) {
uuid1 := uuid.New()
uuid2 := uuid.New()
toAccount := func(a *vmess.Account) Account {
account, err := a.AsAccount()
common.Must(err)
return account
}
spec := NewServerSpec(net.Destination{}, AlwaysValid(), &MemoryUser{
Email: "test1@v2ray.com",
Account: &vmess.Account{Id: uuid1.String()},
Account: toAccount(&vmess.Account{Id: uuid1.String()}),
})
assert(spec.HasUser(&MemoryUser{
Email: "test1@v2ray.com",
Account: &vmess.Account{Id: uuid2.String()},
Account: toAccount(&vmess.Account{Id: uuid2.String()}),
}), IsFalse)
spec.AddUser(&MemoryUser{Email: "test2@v2ray.com"})
assert(spec.HasUser(&MemoryUser{
Email: "test1@v2ray.com",
Account: &vmess.Account{Id: uuid1.String()},
Account: toAccount(&vmess.Account{Id: uuid1.String()}),
}), IsTrue)
}

View File

@ -5,7 +5,6 @@ import (
"time"
"v2ray.com/core/common"
"v2ray.com/core/common/serial"
"v2ray.com/core/common/uuid"
"v2ray.com/core/common/protocol"
@ -20,10 +19,16 @@ func TestUserValidator(t *testing.T) {
v := NewTimedUserValidator(hasher)
defer common.Close(v)
toAccount := func(a *Account) protocol.Account {
account, err := a.AsAccount()
common.Must(err)
return account
}
id := uuid.New()
user := &protocol.User{
user := &protocol.MemoryUser{
Email: "test",
Account: serial.ToTypedMessage(&Account{
Account: toAccount(&Account{
Id: id.String(),
AlterId: 8,
}),