testing

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: GPL-3.0 Imports: 17 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

This section is empty.

Types

type FaultyMockPOWChain

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

FaultyMockPOWChain defines an incorrectly functioning powchain service.

func (*FaultyMockPOWChain) BlockByTimestamp

func (f *FaultyMockPOWChain) BlockByTimestamp(_ context.Context, _ uint64) (*types.HeaderInfo, error)

BlockByTimestamp --

func (*FaultyMockPOWChain) BlockExists

func (f *FaultyMockPOWChain) BlockExists(_ context.Context, _ common.Hash) (bool, *big.Int, error)

BlockExists --

func (*FaultyMockPOWChain) BlockExistsWithCache

func (f *FaultyMockPOWChain) BlockExistsWithCache(ctx context.Context, hash common.Hash) (bool, *big.Int, error)

BlockExistsWithCache --

func (*FaultyMockPOWChain) BlockHashByHeight

func (f *FaultyMockPOWChain) BlockHashByHeight(_ context.Context, _ *big.Int) (common.Hash, error)

BlockHashByHeight --

func (*FaultyMockPOWChain) BlockTimeByHeight

func (f *FaultyMockPOWChain) BlockTimeByHeight(_ context.Context, _ *big.Int) (uint64, error)

BlockTimeByHeight --

func (*FaultyMockPOWChain) ChainStartDeposits

func (f *FaultyMockPOWChain) ChainStartDeposits() []*ethpb.Deposit

ChainStartDeposits --

func (*FaultyMockPOWChain) ChainStartEth1Data

func (f *FaultyMockPOWChain) ChainStartEth1Data() *ethpb.Eth1Data

ChainStartEth1Data --

func (*FaultyMockPOWChain) ClearPreGenesisData

func (f *FaultyMockPOWChain) ClearPreGenesisData()

ClearPreGenesisData --

func (*FaultyMockPOWChain) DepositRoot

func (f *FaultyMockPOWChain) DepositRoot() [32]byte

DepositRoot --

func (*FaultyMockPOWChain) DepositTrie

func (f *FaultyMockPOWChain) DepositTrie() *trie.SparseMerkleTrie

DepositTrie --

func (*FaultyMockPOWChain) Eth2GenesisPowchainInfo

func (f *FaultyMockPOWChain) Eth2GenesisPowchainInfo() (uint64, *big.Int)

Eth2GenesisPowchainInfo --

func (*FaultyMockPOWChain) IsConnectedToETH1

func (f *FaultyMockPOWChain) IsConnectedToETH1() bool

IsConnectedToETH1 --

func (*FaultyMockPOWChain) LatestBlockHeight

func (f *FaultyMockPOWChain) LatestBlockHeight() *big.Int

LatestBlockHeight --

func (*FaultyMockPOWChain) PreGenesisState

func (f *FaultyMockPOWChain) PreGenesisState() state.BeaconState

PreGenesisState --

type POWChain

type POWChain 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
}

POWChain defines a properly functioning mock for the powchain service.

func NewPOWChain

func NewPOWChain() *POWChain

NewPOWChain creates a new mock chain with empty block info.

func (*POWChain) BlockByTimestamp

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

BlockByTimestamp --

func (*POWChain) BlockExists

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

BlockExists --

func (*POWChain) BlockExistsWithCache

func (m *POWChain) BlockExistsWithCache(ctx context.Context, hash common.Hash) (bool, *big.Int, error)

BlockExistsWithCache --

func (*POWChain) BlockHashByHeight

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

BlockHashByHeight --

func (*POWChain) BlockTimeByHeight

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

BlockTimeByHeight --

func (*POWChain) ChainStartDeposits

func (m *POWChain) ChainStartDeposits() []*ethpb.Deposit

ChainStartDeposits --

func (*POWChain) ChainStartEth1Data

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

ChainStartEth1Data --

func (*POWChain) ClearPreGenesisData

func (m *POWChain) ClearPreGenesisData()

ClearPreGenesisData --

func (*POWChain) DepositRoot

func (m *POWChain) DepositRoot() [32]byte

DepositRoot --

func (*POWChain) DepositTrie

func (m *POWChain) DepositTrie() *trie.SparseMerkleTrie

DepositTrie --

func (*POWChain) Eth2GenesisPowchainInfo

func (m *POWChain) Eth2GenesisPowchainInfo() (uint64, *big.Int)

Eth2GenesisPowchainInfo --

func (*POWChain) InsertBlock

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

InsertBlock adds provided block info into the chain.

func (*POWChain) IsConnectedToETH1

func (m *POWChain) IsConnectedToETH1() bool

IsConnectedToETH1 --

func (*POWChain) PreGenesisState

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

PreGenesisState --

type RPCClient

type RPCClient struct {
	Backend *backends.SimulatedBackend
}

RPCClient defines the mock rpc client.

func (*RPCClient) BatchCall

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

BatchCall --

Jump to

Keyboard shortcuts

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