prysm-pulse/validator/keymanager/remote/mock_keymanager.go
Raul Jordan 715aa408e3
Move Web Protos Into Prysm V2 (#9249)
* move web protos

* move web to v2

* update web protos

* gaz

* proto build

* replace mentions of validator v2

* gaz
2021-07-22 19:19:24 +00:00

47 lines
1.2 KiB
Go

package remote
import (
"context"
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v2"
"github.com/prysmaticlabs/prysm/shared/bls"
"github.com/prysmaticlabs/prysm/shared/event"
)
// MockKeymanager --
type MockKeymanager struct {
PublicKeys [][48]byte
ReloadPublicKeysChan chan [][48]byte
ReloadPublicKeysCalled bool
accountsChangedFeed *event.Feed
}
func NewMock() MockKeymanager {
return MockKeymanager{
accountsChangedFeed: new(event.Feed),
ReloadPublicKeysChan: make(chan [][48]byte, 1),
}
}
// FetchValidatingPublicKeys --
func (m *MockKeymanager) FetchValidatingPublicKeys(context.Context) ([][48]byte, error) {
return m.PublicKeys, nil
}
// Sign --
func (*MockKeymanager) Sign(context.Context, *validatorpb.SignRequest) (bls.Signature, error) {
panic("implement me")
}
// SubscribeAccountChanges --
func (m *MockKeymanager) SubscribeAccountChanges(chan [][48]byte) event.Subscription {
return m.accountsChangedFeed.Subscribe(m.ReloadPublicKeysChan)
}
// ReloadPublicKeys --
func (m *MockKeymanager) ReloadPublicKeys(context.Context) ([][48]byte, error) {
m.ReloadPublicKeysCalled = true
m.ReloadPublicKeysChan <- m.PublicKeys
return m.PublicKeys, nil
}