2021-03-16 15:00:05 +00:00
|
|
|
package remote
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-09-18 17:26:11 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/async/event"
|
2022-01-06 17:33:08 +00:00
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
2021-09-15 22:55:11 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
2021-08-18 21:24:01 +00:00
|
|
|
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
|
2021-03-16 15:00:05 +00:00
|
|
|
)
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// MockKeymanager --
|
2021-03-16 15:00:05 +00:00
|
|
|
type MockKeymanager struct {
|
2022-01-06 17:33:08 +00:00
|
|
|
PublicKeys [][fieldparams.BLSPubkeyLength]byte
|
|
|
|
ReloadPublicKeysChan chan [][fieldparams.BLSPubkeyLength]byte
|
2021-04-30 15:15:22 +00:00
|
|
|
ReloadPublicKeysCalled bool
|
|
|
|
accountsChangedFeed *event.Feed
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMock() MockKeymanager {
|
|
|
|
return MockKeymanager{
|
|
|
|
accountsChangedFeed: new(event.Feed),
|
2022-01-06 17:33:08 +00:00
|
|
|
ReloadPublicKeysChan: make(chan [][fieldparams.BLSPubkeyLength]byte, 1),
|
2021-04-30 15:15:22 +00:00
|
|
|
}
|
2021-03-16 15:00:05 +00:00
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// FetchValidatingPublicKeys --
|
2022-01-06 17:33:08 +00:00
|
|
|
func (m *MockKeymanager) FetchValidatingPublicKeys(context.Context) ([][fieldparams.BLSPubkeyLength]byte, error) {
|
2021-03-16 15:00:05 +00:00
|
|
|
return m.PublicKeys, nil
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// Sign --
|
2021-03-16 15:00:05 +00:00
|
|
|
func (*MockKeymanager) Sign(context.Context, *validatorpb.SignRequest) (bls.Signature, error) {
|
|
|
|
panic("implement me")
|
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// SubscribeAccountChanges --
|
2022-01-06 17:33:08 +00:00
|
|
|
func (m *MockKeymanager) SubscribeAccountChanges(chan [][fieldparams.BLSPubkeyLength]byte) event.Subscription {
|
2021-04-30 15:15:22 +00:00
|
|
|
return m.accountsChangedFeed.Subscribe(m.ReloadPublicKeysChan)
|
2021-03-16 15:00:05 +00:00
|
|
|
}
|
|
|
|
|
2021-04-23 12:06:05 +00:00
|
|
|
// ReloadPublicKeys --
|
2022-01-06 17:33:08 +00:00
|
|
|
func (m *MockKeymanager) ReloadPublicKeys(context.Context) ([][fieldparams.BLSPubkeyLength]byte, error) {
|
2021-04-30 15:15:22 +00:00
|
|
|
m.ReloadPublicKeysCalled = true
|
|
|
|
m.ReloadPublicKeysChan <- m.PublicKeys
|
2021-03-16 15:00:05 +00:00
|
|
|
return m.PublicKeys, nil
|
|
|
|
}
|