Documentation ¶
Overview ¶
Package testing includes useful mocks for writing unit tests which depend on logic from the blockchain package.
Index ¶
- type ChainService
- func (ms *ChainService) AttestationPreState(ctx context.Context, att *ethpb.Attestation) (*stateTrie.BeaconState, error)
- func (ms *ChainService) BlockNotifier() blockfeed.Notifier
- func (ms *ChainService) ClearCachedStates()
- func (ms *ChainService) CurrentFork() *pb.Fork
- func (ms *ChainService) CurrentJustifiedCheckpt() *ethpb.Checkpoint
- func (ms *ChainService) CurrentSlot() uint64
- func (ms *ChainService) FinalizedCheckpt() *ethpb.Checkpoint
- func (ms *ChainService) GenesisTime() time.Time
- func (ms *ChainService) GenesisValidatorRoot() [32]byte
- func (ms *ChainService) HasInitSyncBlock(root [32]byte) bool
- func (ms *ChainService) HeadBlock(context.Context) (*ethpb.SignedBeaconBlock, error)
- func (ms *ChainService) HeadGenesisValidatorRoot() [32]byte
- func (ms *ChainService) HeadRoot(ctx context.Context) ([]byte, error)
- func (ms *ChainService) HeadSeed(epoch uint64) ([32]byte, error)
- func (ms *ChainService) HeadSlot() uint64
- func (ms *ChainService) HeadState(context.Context) (*stateTrie.BeaconState, error)
- func (ms *ChainService) HeadValidatorsIndices(epoch uint64) ([]uint64, error)
- func (ms *ChainService) IsValidAttestation(ctx context.Context, att *ethpb.Attestation) bool
- func (ms *ChainService) OperationNotifier() opfeed.Notifier
- func (ms *ChainService) Participation(epoch uint64) *precompute.Balance
- func (ms *ChainService) PreviousJustifiedCheckpt() *ethpb.Checkpoint
- func (ms *ChainService) ReceiveAttestation(context.Context, *ethpb.Attestation) error
- func (ms *ChainService) ReceiveAttestationNoPubsub(context.Context, *ethpb.Attestation) error
- func (ms *ChainService) ReceiveBlock(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
- func (ms *ChainService) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
- func (ms *ChainService) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
- func (ms *ChainService) ReceiveBlockNoVerify(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
- func (ms *ChainService) StateNotifier() statefeed.Notifier
- type MockBlockNotifier
- type MockOperationNotifier
- type MockStateNotifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainService ¶
type ChainService struct { State *stateTrie.BeaconState Root []byte Block *ethpb.SignedBeaconBlock FinalizedCheckPoint *ethpb.Checkpoint CurrentJustifiedCheckPoint *ethpb.Checkpoint PreviousJustifiedCheckPoint *ethpb.Checkpoint BlocksReceived []*ethpb.SignedBeaconBlock Balance *precompute.Balance Genesis time.Time ValidatorsRoot [32]byte Fork *pb.Fork DB db.Database ValidAttestation bool // contains filtered or unexported fields }
ChainService defines the mock interface for testing
func (*ChainService) AttestationPreState ¶
func (ms *ChainService) AttestationPreState(ctx context.Context, att *ethpb.Attestation) (*stateTrie.BeaconState, error)
AttestationPreState mocks AttestationPreState method in chain service.
func (*ChainService) BlockNotifier ¶
func (ms *ChainService) BlockNotifier() blockfeed.Notifier
BlockNotifier mocks the same method in the chain service.
func (*ChainService) ClearCachedStates ¶
func (ms *ChainService) ClearCachedStates()
ClearCachedStates does nothing.
func (*ChainService) CurrentFork ¶
func (ms *ChainService) CurrentFork() *pb.Fork
CurrentFork mocks HeadState method in chain service.
func (*ChainService) CurrentJustifiedCheckpt ¶
func (ms *ChainService) CurrentJustifiedCheckpt() *ethpb.Checkpoint
CurrentJustifiedCheckpt mocks CurrentJustifiedCheckpt method in chain service.
func (*ChainService) CurrentSlot ¶
func (ms *ChainService) CurrentSlot() uint64
CurrentSlot mocks the same method in the chain service.
func (*ChainService) FinalizedCheckpt ¶
func (ms *ChainService) FinalizedCheckpt() *ethpb.Checkpoint
FinalizedCheckpt mocks FinalizedCheckpt method in chain service.
func (*ChainService) GenesisTime ¶
func (ms *ChainService) GenesisTime() time.Time
GenesisTime mocks the same method in the chain service.
func (*ChainService) GenesisValidatorRoot ¶
func (ms *ChainService) GenesisValidatorRoot() [32]byte
GenesisValidatorRoot mocks the same method in the chain service.
func (*ChainService) HasInitSyncBlock ¶
func (ms *ChainService) HasInitSyncBlock(root [32]byte) bool
HasInitSyncBlock mocks the same method in the chain service.
func (*ChainService) HeadBlock ¶
func (ms *ChainService) HeadBlock(context.Context) (*ethpb.SignedBeaconBlock, error)
HeadBlock mocks HeadBlock method in chain service.
func (*ChainService) HeadGenesisValidatorRoot ¶
func (ms *ChainService) HeadGenesisValidatorRoot() [32]byte
HeadGenesisValidatorRoot mocks HeadGenesisValidatorRoot method in chain service.
func (*ChainService) HeadRoot ¶
func (ms *ChainService) HeadRoot(ctx context.Context) ([]byte, error)
HeadRoot mocks HeadRoot method in chain service.
func (*ChainService) HeadSeed ¶
func (ms *ChainService) HeadSeed(epoch uint64) ([32]byte, error)
HeadSeed mocks the same method in the chain service.
func (*ChainService) HeadSlot ¶
func (ms *ChainService) HeadSlot() uint64
HeadSlot mocks HeadSlot method in chain service.
func (*ChainService) HeadState ¶
func (ms *ChainService) HeadState(context.Context) (*stateTrie.BeaconState, error)
HeadState mocks HeadState method in chain service.
func (*ChainService) HeadValidatorsIndices ¶
func (ms *ChainService) HeadValidatorsIndices(epoch uint64) ([]uint64, error)
HeadValidatorsIndices mocks the same method in the chain service.
func (*ChainService) IsValidAttestation ¶
func (ms *ChainService) IsValidAttestation(ctx context.Context, att *ethpb.Attestation) bool
IsValidAttestation always returns true.
func (*ChainService) OperationNotifier ¶
func (ms *ChainService) OperationNotifier() opfeed.Notifier
OperationNotifier mocks the same method in the chain service.
func (*ChainService) Participation ¶
func (ms *ChainService) Participation(epoch uint64) *precompute.Balance
Participation mocks the same method in the chain service.
func (*ChainService) PreviousJustifiedCheckpt ¶
func (ms *ChainService) PreviousJustifiedCheckpt() *ethpb.Checkpoint
PreviousJustifiedCheckpt mocks PreviousJustifiedCheckpt method in chain service.
func (*ChainService) ReceiveAttestation ¶
func (ms *ChainService) ReceiveAttestation(context.Context, *ethpb.Attestation) error
ReceiveAttestation mocks ReceiveAttestation method in chain service.
func (*ChainService) ReceiveAttestationNoPubsub ¶
func (ms *ChainService) ReceiveAttestationNoPubsub(context.Context, *ethpb.Attestation) error
ReceiveAttestationNoPubsub mocks ReceiveAttestationNoPubsub method in chain service.
func (*ChainService) ReceiveBlock ¶
func (ms *ChainService) ReceiveBlock(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
ReceiveBlock mocks ReceiveBlock method in chain service.
func (*ChainService) ReceiveBlockNoPubsub ¶
func (ms *ChainService) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
ReceiveBlockNoPubsub mocks ReceiveBlockNoPubsub method in chain service.
func (*ChainService) ReceiveBlockNoPubsubForkchoice ¶
func (ms *ChainService) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
ReceiveBlockNoPubsubForkchoice mocks ReceiveBlockNoPubsubForkchoice method in chain service.
func (*ChainService) ReceiveBlockNoVerify ¶
func (ms *ChainService) ReceiveBlockNoVerify(ctx context.Context, block *ethpb.SignedBeaconBlock, blockRoot [32]byte) error
ReceiveBlockNoVerify mocks ReceiveBlockNoVerify method in chain service.
func (*ChainService) StateNotifier ¶
func (ms *ChainService) StateNotifier() statefeed.Notifier
StateNotifier mocks the same method in the chain service.
type MockBlockNotifier ¶
type MockBlockNotifier struct {
// contains filtered or unexported fields
}
MockBlockNotifier mocks the block notifier.
func (*MockBlockNotifier) BlockFeed ¶
func (msn *MockBlockNotifier) BlockFeed() *event.Feed
BlockFeed returns a block feed.
type MockOperationNotifier ¶
type MockOperationNotifier struct {
// contains filtered or unexported fields
}
MockOperationNotifier mocks the operation notifier.
func (*MockOperationNotifier) OperationFeed ¶
func (mon *MockOperationNotifier) OperationFeed() *event.Feed
OperationFeed returns an operation feed.
type MockStateNotifier ¶
type MockStateNotifier struct {
// contains filtered or unexported fields
}
MockStateNotifier mocks the state notifier.
func (*MockStateNotifier) StateFeed ¶
func (msn *MockStateNotifier) StateFeed() *event.Feed
StateFeed returns a state feed.