2015-09-14 17:03:31 +00:00
|
|
|
package mocks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/v2ray/v2ray-core"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MockUserSet struct {
|
|
|
|
UserIds []core.ID
|
|
|
|
UserHashes map[string]int
|
|
|
|
}
|
|
|
|
|
|
|
|
func (us *MockUserSet) AddUser(user core.User) error {
|
|
|
|
us.UserIds = append(us.UserIds, user.Id)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-14 23:32:55 +00:00
|
|
|
func (us *MockUserSet) GetUser(userhash []byte) (*core.ID, int64, bool) {
|
2015-09-14 17:03:31 +00:00
|
|
|
idx, found := us.UserHashes[string(userhash)]
|
|
|
|
if found {
|
2015-09-14 23:32:55 +00:00
|
|
|
return &us.UserIds[idx], 1234, true
|
2015-09-14 17:03:31 +00:00
|
|
|
}
|
2015-09-14 23:32:55 +00:00
|
|
|
return nil, 0, false
|
2015-09-14 17:03:31 +00:00
|
|
|
}
|