tests_utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePrivateKey

func GeneratePrivateKey() (*ecdsa.PrivateKey, error)

func MakeGenesisHeader

func MakeGenesisHeader(validators []common.Address) *types.Header

func MakeNodeKey

func MakeNodeKey() *ecdsa.PrivateKey

func PrepareExtra

func PrepareExtra(header *types.Header) ([]byte, error)

PrepareExtra returns a extra-data of the given header and validators

Types

type MockBlockChain

type MockBlockChain struct {
	Statedb          *state.StateDB
	GasLimit         uint64
	ChainHeadFeed    *event.Feed
	MockCurrentBlock *types.Block
}

MockBlockChain is mock struct for block chain

func (*MockBlockChain) CurrentBlock

func (bc *MockBlockChain) CurrentBlock() *types.Block

func (*MockBlockChain) GetBlock

func (bc *MockBlockChain) GetBlock(hash common.Hash, number uint64) *types.Block

func (*MockBlockChain) StateAt

func (bc *MockBlockChain) StateAt(common.Hash) (*state.StateDB, error)

type MockChainReader

type MockChainReader struct {
	GenesisHeader *types.Header
	*MockBlockChain
	Address common.Address
	Trigger *bool
}

MockChainReader is mock struct for chain reader, it serves basic block/ state reading for testing purposes

func GenerateMockChainReader

func GenerateMockChainReader() (*MockChainReader, error)

func (*MockChainReader) Config

func (c *MockChainReader) Config() *params.ChainConfig

func (*MockChainReader) CurrentHeader

func (c *MockChainReader) CurrentHeader() *types.Header

func (*MockChainReader) GetHeader

func (c *MockChainReader) GetHeader(hash common.Hash, blockNumber uint64) *types.Header

GetHeader implement a mock version of chainReader.GetHeader It returns correctParentHeader with Number set to input blockNumber

func (*MockChainReader) GetHeaderByHash

func (c *MockChainReader) GetHeaderByHash(hash common.Hash) *types.Header

func (*MockChainReader) GetHeaderByNumber

func (c *MockChainReader) GetHeaderByNumber(blockNumber uint64) *types.Header

GetHeaderByNumber implement a mock version of chainReader.GetHeaderByNumber It returns genesis Header if blockNumber is 0, else return an empty Header

func (*MockChainReader) State

func (c *MockChainReader) State() (*state.StateDB, error)

State is used multiple times to reset the pending state. when simulate is true it will create a state that indicates that tx0 and tx1 are included in the chain.

Jump to

Keyboard shortcuts

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