mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
af07c13730
* add main.go * interop readme * proper visibility * standardize and abstract into simpler funcs * formatting * no os pkg * add test * no panics anywhere, properly and nicely handle errors * proper comments * fix broken test * readme * comment * recommend ssz * install * tool now works * README * build * readme * 64 validators * rem print * register the no powchain flag * work on mock eth1 start * common interface * getting closer with the interface defs * only two uses of powchain * remove powchain dependency * remove powchain dependency * common powchain interface * proper comment in case of flag * proper args into rpc services * rename fields * pass in mock flag into RPC * conforms to iface * use client instead of block fetcher iface * broken tests * block fetcher * finalized * resolved broken build * fix build * comment * fix tests * tests pass * resolved confs * took them out * rename into smaller interfaces * resolve some confs * ensure tests pass * properly utilize mock instead of localized mock * res lint * lint * finish test for mock eth1data * run gazelle * include flag again * fix broken build * disable powchain * dont dial eth1 nodes * reenable pow * use smaller interfaces, standardize naming * abstract mock into its own package * faulty mock lint * fix stutter in lint * rpc tests all passing * use mocks for operations * no more mocks in the entire rpc package * no mock * viz * testonly
80 lines
2.2 KiB
Go
80 lines
2.2 KiB
Go
package testing
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/event"
|
|
)
|
|
|
|
// ChainService defines the mock interface for testing
|
|
type ChainService struct {
|
|
State *pb.BeaconState
|
|
Root []byte
|
|
FinalizedCheckPoint *ethpb.Checkpoint
|
|
}
|
|
|
|
// ReceiveBlock mocks ReceiveBlock method in chain service.
|
|
func (ms *ChainService) ReceiveBlock(ctx context.Context, block *ethpb.BeaconBlock) error {
|
|
return nil
|
|
}
|
|
|
|
// ReceiveBlockNoPubsub mocks ReceiveBlockNoPubsub method in chain service.
|
|
func (ms *ChainService) ReceiveBlockNoPubsub(ctx context.Context, block *ethpb.BeaconBlock) error {
|
|
return nil
|
|
}
|
|
|
|
// ReceiveBlockNoPubsubForkchoice mocks ReceiveBlockNoPubsubForkchoice method in chain service.
|
|
func (ms *ChainService) ReceiveBlockNoPubsubForkchoice(ctx context.Context, block *ethpb.BeaconBlock) error {
|
|
return nil
|
|
}
|
|
|
|
// HeadSlot mocks HeadSlot method in chain service.
|
|
func (ms *ChainService) HeadSlot() uint64 {
|
|
return ms.State.Slot
|
|
|
|
}
|
|
|
|
// HeadRoot mocks HeadRoot method in chain service.
|
|
func (ms *ChainService) HeadRoot() []byte {
|
|
return ms.Root
|
|
|
|
}
|
|
|
|
// HeadBlock mocks HeadBlock method in chain service.
|
|
func (ms *ChainService) HeadBlock() *ethpb.BeaconBlock {
|
|
return nil
|
|
}
|
|
|
|
// HeadState mocks HeadState method in chain service.
|
|
func (ms *ChainService) HeadState() *pb.BeaconState {
|
|
return ms.State
|
|
}
|
|
|
|
// FinalizedCheckpt mocks FinalizedCheckpt method in chain service.
|
|
func (ms *ChainService) FinalizedCheckpt() *ethpb.Checkpoint {
|
|
return ms.FinalizedCheckPoint
|
|
}
|
|
|
|
// ReceiveAttestation mocks ReceiveAttestation method in chain service.
|
|
func (ms *ChainService) ReceiveAttestation(context.Context, *ethpb.Attestation) error {
|
|
return nil
|
|
}
|
|
|
|
// ReceiveAttestationNoPubsub mocks ReceiveAttestationNoPubsub method in chain service.
|
|
func (ms *ChainService) ReceiveAttestationNoPubsub(context.Context, *ethpb.Attestation) error {
|
|
return nil
|
|
}
|
|
|
|
// GenesisTime mocks the same method in the chain service.
|
|
func (ms *ChainService) GenesisTime() time.Time {
|
|
return time.Now()
|
|
}
|
|
|
|
// StateInitializedFeed mocks the same method in the chain service.
|
|
func (ms *ChainService) StateInitializedFeed() *event.Feed {
|
|
return new(event.Feed)
|
|
}
|