mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 11:11:20 +00:00
943dec525c
* Delete deploy contract tool. Move mock to its own package as testonly with some helper functions * gofmt contracts/deposit/mock/mock.go * move stategen mock.go to its on testonly pkg * move password_reader_mock.go to mock testonly package * move mock keymanager to its own testonly package * move attestations mock * move voluntaryexits mock * Move slashings mock to mock pkg * move the slasher mock Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/prysmaticlabs/prysm/async/event"
|
|
fieldparams "github.com/prysmaticlabs/prysm/config/fieldparams"
|
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
|
validatorpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/validator-client"
|
|
)
|
|
|
|
// 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
|
|
}
|