mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 03:01:19 +00:00
ade7d705ec
* Migrating Keymanager account list functionality into each keymanager type * Addressing review comments * Adding newline at end of BUILD.bazel * bazel run //:gazelle -- fix * account deleter cleanup * bazel run //:gazelle -- fix * remove stale logging statement * adding deleter interface to mock functions * fixing deepsource findings * go.sum * bazel run //:gazelle -- fix * go mod t-dy -compat=1.17 Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com> Co-authored-by: prestonvanloon <preston@prysmaticlabs.com>
69 lines
2.1 KiB
Go
69 lines
2.1 KiB
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/prysmaticlabs/prysm/async/event"
|
|
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
|
ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service"
|
|
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
|
|
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
|
)
|
|
|
|
// MockKeymanager --
|
|
type MockKeymanager struct {
|
|
PublicKeys [][fieldparams.BLSPubkeyLength]byte
|
|
ReloadPublicKeysChan chan [][fieldparams.BLSPubkeyLength]byte
|
|
ReloadPublicKeysCalled bool
|
|
accountsChangedFeed *event.Feed
|
|
}
|
|
|
|
func NewMock() MockKeymanager {
|
|
return MockKeymanager{
|
|
accountsChangedFeed: new(event.Feed),
|
|
ReloadPublicKeysChan: make(chan [][fieldparams.BLSPubkeyLength]byte, 1),
|
|
}
|
|
}
|
|
|
|
// FetchValidatingPublicKeys --
|
|
func (m *MockKeymanager) FetchValidatingPublicKeys(context.Context) ([][fieldparams.BLSPubkeyLength]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 [][fieldparams.BLSPubkeyLength]byte) event.Subscription {
|
|
return m.accountsChangedFeed.Subscribe(m.ReloadPublicKeysChan)
|
|
}
|
|
|
|
// ReloadPublicKeys --
|
|
func (m *MockKeymanager) ReloadPublicKeys(context.Context) ([][fieldparams.BLSPubkeyLength]byte, error) {
|
|
m.ReloadPublicKeysCalled = true
|
|
m.ReloadPublicKeysChan <- m.PublicKeys
|
|
return m.PublicKeys, nil
|
|
}
|
|
|
|
// ExtractKeystores --
|
|
func (*MockKeymanager) ExtractKeystores(
|
|
ctx context.Context, publicKeys []bls.PublicKey, password string,
|
|
) ([]*keymanager.Keystore, error) {
|
|
return nil, errors.New("extracting keys not supported for a remote keymanager")
|
|
}
|
|
|
|
// ListKeymanagerAccounts --
|
|
func (*MockKeymanager) ListKeymanagerAccounts(
|
|
context.Context, keymanager.ListKeymanagerAccountConfig) error {
|
|
return nil
|
|
}
|
|
|
|
func (*MockKeymanager) DeleteKeystores(context.Context, [][]byte,
|
|
) ([]*ethpbservice.DeletedKeystoreStatus, error) {
|
|
return nil, nil
|
|
}
|