mirror of https://github.com/v2ray/v2ray-core
fix test break
parent
54e1bb96cc
commit
16051587b5
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}),
|
||||
|
|
Loading…
Reference in New Issue