testing

package
v4.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package testing provides useful mocks for an eth1 powchain service as needed by unit tests for the beacon node.

Index

Constants

This section is empty.

Variables

View Source
var GenesisTime = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC).Unix()

GenesisTime represents a static past date - JAN 01 2000.

Functions

func SetupRPCServer

func SetupRPCServer() (*rpc.Server, string, error)

Types

type Chain

type Chain struct {
	ChainFeed         *event.Feed
	LatestBlockNumber *big.Int
	HashesByHeight    map[int][]byte
	TimesByHeight     map[int]uint64
	BlockNumberByTime map[uint64]*big.Int
	Eth1Data          *ethpb.Eth1Data
	GenesisEth1Block  *big.Int
	GenesisState      state.BeaconState
	CurrEndpoint      string
	CurrError         error
	Endpoints         []string
	Errors            []error
}

Chain defines a properly functioning mock for the powchain service.

func New

func New() *Chain

New creates a new mock chain with empty block info.

func (*Chain) BlockByTimestamp

func (m *Chain) BlockByTimestamp(_ context.Context, time uint64) (*types.HeaderInfo, error)

BlockByTimestamp --

func (*Chain) BlockExists

func (m *Chain) BlockExists(_ context.Context, hash common.Hash) (bool, *big.Int, error)

BlockExists --

func (*Chain) BlockHashByHeight

func (m *Chain) BlockHashByHeight(_ context.Context, height *big.Int) (common.Hash, error)

BlockHashByHeight --

func (*Chain) BlockTimeByHeight

func (m *Chain) BlockTimeByHeight(_ context.Context, height *big.Int) (uint64, error)

BlockTimeByHeight --

func (*Chain) ChainStartEth1Data

func (m *Chain) ChainStartEth1Data() *ethpb.Eth1Data

ChainStartEth1Data --

func (*Chain) ClearPreGenesisData

func (*Chain) ClearPreGenesisData()

ClearPreGenesisData --

func (*Chain) ETH1ConnectionErrors

func (m *Chain) ETH1ConnectionErrors() []error

func (*Chain) ETH1Endpoints

func (m *Chain) ETH1Endpoints() []string

func (*Chain) ExecutionClientConnected

func (*Chain) ExecutionClientConnected() bool

func (*Chain) ExecutionClientConnectionErr

func (m *Chain) ExecutionClientConnectionErr() error

func (*Chain) ExecutionClientEndpoint

func (m *Chain) ExecutionClientEndpoint() string

func (*Chain) GenesisExecutionChainInfo

func (m *Chain) GenesisExecutionChainInfo() (uint64, *big.Int)

GenesisExecutionChainInfo --

func (*Chain) InsertBlock

func (m *Chain) InsertBlock(height int, time uint64, hash []byte) *Chain

InsertBlock adds provided block info into the chain.

func (*Chain) PreGenesisState

func (m *Chain) PreGenesisState() state.BeaconState

PreGenesisState --

type EngineClient

type EngineClient struct {
	NewPayloadResp              []byte
	PayloadIDBytes              *pb.PayloadIDBytes
	ForkChoiceUpdatedResp       []byte
	ExecutionPayload            *pb.ExecutionPayload
	ExecutionPayloadCapella     *pb.ExecutionPayloadCapella
	ExecutionBlock              *pb.ExecutionBlock
	Err                         error
	ErrLatestExecBlock          error
	ErrExecBlockByHash          error
	ErrForkchoiceUpdated        error
	ErrNewPayload               error
	ErrGetPayload               error
	ExecutionPayloadByBlockHash map[[32]byte]*pb.ExecutionPayload
	BlockByHashMap              map[[32]byte]*pb.ExecutionBlock
	NumReconstructedPayloads    uint64
	TerminalBlockHash           []byte
	TerminalBlockHashExists     bool
	OverrideValidHash           [32]byte
	BlockValue                  uint64
}

EngineClient --

func (*EngineClient) ExchangeTransitionConfiguration

func (e *EngineClient) ExchangeTransitionConfiguration(_ context.Context, _ *pb.TransitionConfiguration) error

ExchangeTransitionConfiguration --

func (*EngineClient) ExecutionBlockByHash

func (e *EngineClient) ExecutionBlockByHash(_ context.Context, h common.Hash, _ bool) (*pb.ExecutionBlock, error)

ExecutionBlockByHash --

func (*EngineClient) ForkchoiceUpdated

ForkchoiceUpdated --

func (*EngineClient) GetPayload

GetPayload --

func (*EngineClient) GetTerminalBlockHash

func (e *EngineClient) GetTerminalBlockHash(ctx context.Context, transitionTime uint64) ([]byte, bool, error)

GetTerminalBlockHash --

func (*EngineClient) LatestExecutionBlock

func (e *EngineClient) LatestExecutionBlock(_ context.Context) (*pb.ExecutionBlock, error)

LatestExecutionBlock --

func (*EngineClient) NewPayload

func (e *EngineClient) NewPayload(_ context.Context, _ interfaces.ExecutionData) ([]byte, error)

NewPayload --

func (*EngineClient) ReconstructFullBellatrixBlockBatch

func (e *EngineClient) ReconstructFullBellatrixBlockBatch(
	ctx context.Context, blindedBlocks []interfaces.ReadOnlySignedBeaconBlock,
) ([]interfaces.SignedBeaconBlock, error)

ReconstructFullBellatrixBlockBatch --

func (*EngineClient) ReconstructFullBlock

func (e *EngineClient) ReconstructFullBlock(
	_ context.Context, blindedBlock interfaces.ReadOnlySignedBeaconBlock,
) (interfaces.SignedBeaconBlock, error)

ReconstructFullBlock --

type FaultyExecutionChain

type FaultyExecutionChain struct {
	ChainFeed      *event.Feed
	HashesByHeight map[int][]byte
}

FaultyExecutionChain defines an incorrectly functioning powchain service.

func (*FaultyExecutionChain) BlockByTimestamp

BlockByTimestamp --

func (*FaultyExecutionChain) BlockExists

BlockExists --

func (*FaultyExecutionChain) BlockHashByHeight

func (*FaultyExecutionChain) BlockHashByHeight(context.Context, *big.Int) (common.Hash, error)

BlockHashByHeight --

func (*FaultyExecutionChain) BlockTimeByHeight

func (*FaultyExecutionChain) BlockTimeByHeight(context.Context, *big.Int) (uint64, error)

BlockTimeByHeight --

func (*FaultyExecutionChain) ChainStartEth1Data

func (*FaultyExecutionChain) ChainStartEth1Data() *ethpb.Eth1Data

ChainStartEth1Data --

func (*FaultyExecutionChain) ClearPreGenesisData

func (*FaultyExecutionChain) ClearPreGenesisData()

ClearPreGenesisData --

func (*FaultyExecutionChain) Eth2GenesisPowchainInfo

func (*FaultyExecutionChain) Eth2GenesisPowchainInfo() (uint64, *big.Int)

Eth2GenesisPowchainInfo --

func (*FaultyExecutionChain) IsConnectedToETH1

func (*FaultyExecutionChain) IsConnectedToETH1() bool

IsConnectedToETH1 --

func (*FaultyExecutionChain) PreGenesisState

func (*FaultyExecutionChain) PreGenesisState() state.BeaconState

PreGenesisState --

type RPCClient

type RPCClient struct {
	Backend     *backends.SimulatedBackend
	BlockNumMap map[uint64]*types.HeaderInfo
}

RPCClient defines the mock rpc client.

func (*RPCClient) BatchCall

func (r *RPCClient) BatchCall(b []rpc.BatchElem) error

BatchCall --

func (*RPCClient) CallContext

func (r *RPCClient) CallContext(ctx context.Context, obj interface{}, methodName string, args ...interface{}) error

func (*RPCClient) Close

func (*RPCClient) Close()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL