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