mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 21:07:18 +00:00
7cc32c4dda
* remove unused code * remove defer use in loop * Remove unused methods and constants * gofmt and gaz * nilness check * remove unused args * Add TODO for refactoring subscribeWithBase to remove unused arg. It seems too involved to include in this sweeping PR. https://github.com/prysmaticlabs/prysm/issues/7437 * replace empty slice declaration * Remove unnecessary type conversions * remove redundant type declaration * rename receivers to be consistent * Remove bootnode query tool. It is now obsolete by discv5 * Remove relay node. It is no longer used or supported * Revert "Remove relay node. It is no longer used or supported" This reverts commit 4bd7717334dad85ef4766ed9bc4da711fb5fa810. * Delete unused test directory * Delete unsupported gcp startup script * Delete old k8s script * build fixes * fix build * go mod tidy * revert slasher/db/kv/block_header.go * fix build * remove redundant nil check * combine func args Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
179 lines
5.1 KiB
Go
179 lines
5.1 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/timeutils"
|
|
)
|
|
|
|
var _ Validator = (*FakeValidator)(nil)
|
|
|
|
// FakeValidator for mocking.
|
|
type FakeValidator struct {
|
|
DoneCalled bool
|
|
WaitForWalletInitializationCalled bool
|
|
WaitForActivationCalled bool
|
|
WaitForChainStartCalled bool
|
|
WaitForSyncCalled bool
|
|
WaitForSyncedCalled bool
|
|
SlasherReadyCalled bool
|
|
NextSlotCalled bool
|
|
CanonicalHeadSlotCalled bool
|
|
UpdateDutiesCalled bool
|
|
UpdateProtectionsCalled bool
|
|
RoleAtCalled bool
|
|
AttestToBlockHeadCalled bool
|
|
ProposeBlockCalled bool
|
|
LogValidatorGainsAndLossesCalled bool
|
|
SaveProtectionsCalled bool
|
|
SlotDeadlineCalled bool
|
|
ProposeBlockArg1 uint64
|
|
AttestToBlockHeadArg1 uint64
|
|
RoleAtArg1 uint64
|
|
UpdateDutiesArg1 uint64
|
|
NextSlotRet <-chan uint64
|
|
PublicKey string
|
|
UpdateDutiesRet error
|
|
RolesAtRet []ValidatorRole
|
|
Balances map[[48]byte]uint64
|
|
IndexToPubkeyMap map[uint64][48]byte
|
|
PubkeyToIndexMap map[[48]byte]uint64
|
|
PubkeysToStatusesMap map[[48]byte]ethpb.ValidatorStatus
|
|
}
|
|
|
|
// Done for mocking.
|
|
func (fv *FakeValidator) Done() {
|
|
fv.DoneCalled = true
|
|
}
|
|
|
|
// WaitForWalletInitialization for mocking.
|
|
func (fv *FakeValidator) WaitForWalletInitialization(_ context.Context) error {
|
|
fv.WaitForWalletInitializationCalled = true
|
|
return nil
|
|
}
|
|
|
|
// WaitForChainStart for mocking.
|
|
func (fv *FakeValidator) WaitForChainStart(_ context.Context) error {
|
|
fv.WaitForChainStartCalled = true
|
|
return nil
|
|
}
|
|
|
|
// WaitForActivation for mocking.
|
|
func (fv *FakeValidator) WaitForActivation(_ context.Context) error {
|
|
fv.WaitForActivationCalled = true
|
|
return nil
|
|
}
|
|
|
|
// WaitForSync for mocking.
|
|
func (fv *FakeValidator) WaitForSync(_ context.Context) error {
|
|
fv.WaitForSyncCalled = true
|
|
return nil
|
|
}
|
|
|
|
// WaitForSynced for mocking.
|
|
func (fv *FakeValidator) WaitForSynced(_ context.Context) error {
|
|
fv.WaitForSyncedCalled = true
|
|
return nil
|
|
}
|
|
|
|
// SlasherReady for mocking.
|
|
func (fv *FakeValidator) SlasherReady(_ context.Context) error {
|
|
fv.SlasherReadyCalled = true
|
|
return nil
|
|
}
|
|
|
|
// CanonicalHeadSlot for mocking.
|
|
func (fv *FakeValidator) CanonicalHeadSlot(_ context.Context) (uint64, error) {
|
|
fv.CanonicalHeadSlotCalled = true
|
|
return 0, nil
|
|
}
|
|
|
|
// SlotDeadline for mocking.
|
|
func (fv *FakeValidator) SlotDeadline(_ uint64) time.Time {
|
|
fv.SlotDeadlineCalled = true
|
|
return timeutils.Now()
|
|
}
|
|
|
|
// NextSlot for mocking.
|
|
func (fv *FakeValidator) NextSlot() <-chan uint64 {
|
|
fv.NextSlotCalled = true
|
|
return fv.NextSlotRet
|
|
}
|
|
|
|
// UpdateDuties for mocking.
|
|
func (fv *FakeValidator) UpdateDuties(_ context.Context, slot uint64) error {
|
|
fv.UpdateDutiesCalled = true
|
|
fv.UpdateDutiesArg1 = slot
|
|
return fv.UpdateDutiesRet
|
|
}
|
|
|
|
// UpdateProtections for mocking.
|
|
func (fv *FakeValidator) UpdateProtections(_ context.Context, _ uint64) error {
|
|
fv.UpdateProtectionsCalled = true
|
|
return nil
|
|
}
|
|
|
|
// LogValidatorGainsAndLosses for mocking.
|
|
func (fv *FakeValidator) LogValidatorGainsAndLosses(_ context.Context, _ uint64) error {
|
|
fv.LogValidatorGainsAndLossesCalled = true
|
|
return nil
|
|
}
|
|
|
|
// SaveProtections for mocking.
|
|
func (fv *FakeValidator) SaveProtections(_ context.Context) error {
|
|
fv.SaveProtectionsCalled = true
|
|
return nil
|
|
}
|
|
|
|
// RolesAt for mocking.
|
|
func (fv *FakeValidator) RolesAt(_ context.Context, slot uint64) (map[[48]byte][]ValidatorRole, error) {
|
|
fv.RoleAtCalled = true
|
|
fv.RoleAtArg1 = slot
|
|
vr := make(map[[48]byte][]ValidatorRole)
|
|
vr[[48]byte{1}] = fv.RolesAtRet
|
|
return vr, nil
|
|
}
|
|
|
|
// SubmitAttestation for mocking.
|
|
func (fv *FakeValidator) SubmitAttestation(_ context.Context, slot uint64, _ [48]byte) {
|
|
fv.AttestToBlockHeadCalled = true
|
|
fv.AttestToBlockHeadArg1 = slot
|
|
}
|
|
|
|
// ProposeBlock for mocking.
|
|
func (fv *FakeValidator) ProposeBlock(_ context.Context, slot uint64, _ [48]byte) {
|
|
fv.ProposeBlockCalled = true
|
|
fv.ProposeBlockArg1 = slot
|
|
}
|
|
|
|
// SubmitAggregateAndProof for mocking.
|
|
func (fv *FakeValidator) SubmitAggregateAndProof(_ context.Context, _ uint64, _ [48]byte) {}
|
|
|
|
// LogAttestationsSubmitted for mocking.
|
|
func (fv *FakeValidator) LogAttestationsSubmitted() {}
|
|
|
|
// UpdateDomainDataCaches for mocking.
|
|
func (fv *FakeValidator) UpdateDomainDataCaches(context.Context, uint64) {}
|
|
|
|
// BalancesByPubkeys for mocking.
|
|
func (fv *FakeValidator) BalancesByPubkeys(_ context.Context) map[[48]byte]uint64 {
|
|
return fv.Balances
|
|
}
|
|
|
|
// IndicesToPubkeys for mocking.
|
|
func (fv *FakeValidator) IndicesToPubkeys(_ context.Context) map[uint64][48]byte {
|
|
return fv.IndexToPubkeyMap
|
|
}
|
|
|
|
// PubkeysToIndices for mocking.
|
|
func (fv *FakeValidator) PubkeysToIndices(_ context.Context) map[[48]byte]uint64 {
|
|
return fv.PubkeyToIndexMap
|
|
}
|
|
|
|
// PubkeysToStatuses for mocking.
|
|
func (fv *FakeValidator) PubkeysToStatuses(_ context.Context) map[[48]byte]ethpb.ValidatorStatus {
|
|
return fv.PubkeysToStatusesMap
|
|
}
|