consensustest

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: GPL-3.0, GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockBroadcaster

type MockBroadcaster struct{}

func (*MockBroadcaster) Enqueue

func (b *MockBroadcaster) Enqueue(id string, block *types.Block)

func (*MockBroadcaster) FindPeers

func (b *MockBroadcaster) FindPeers(targets map[enode.ID]bool, purpose p2p.PurposeFlag) map[enode.ID]consensus.Peer

type MockEngine

type MockEngine struct {
	consensus.Engine
	// contains filtered or unexported fields
}

MockEngine provides a minimal fake implementation of a consensus engine for use in blockchain tests.

func NewFakeDelayer

func NewFakeDelayer(delay time.Duration) *MockEngine

NewFakeDelayer creates a MockEngine consensus engine that accepts all blocks as valid, but delays verifications by some time, though they still have to conform to the Ethereum consensus rules.

func NewFakeFailer

func NewFakeFailer(blockNumber uint64) *MockEngine

NewFakeFailer creates a MockEngine consensus engine that accepts all blocks as valid apart from the single one specified, though they still have to conform to the Ethereum consensus rules.

func NewFaker

func NewFaker() *MockEngine

NewFaker creates a MockEngine consensus engine that accepts all blocks' seal as valid, though they still have to conform to the Ethereum consensus rules.

func NewFullFaker

func NewFullFaker() *MockEngine

NewFullFaker creates an MockEngine consensus engine with a full fake scheme that accepts all blocks as valid, without checking any consensus rules whatsoever.

func (*MockEngine) APIs

func (e *MockEngine) APIs(chain consensus.ChainHeaderReader) []rpc.API

APIs implements consensus.Engine, returning the user facing RPC APIs.

func (*MockEngine) Author

func (e *MockEngine) Author(header *types.Header) (common.Address, error)

func (*MockEngine) Close

func (e *MockEngine) Close() error

Close closes the exit channel to notify all backend threads exiting.

func (*MockEngine) EpochSize

func (e *MockEngine) EpochSize() uint64

EpochSize size of the epoch

func (*MockEngine) Finalize

func (e *MockEngine) Finalize(chain consensus.ChainHeaderReader, header *types.Header, statedb *state.StateDB, txs []*types.Transaction)

func (*MockEngine) FinalizeAndAssemble

func (e *MockEngine) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, statedb *state.StateDB, txs []*types.Transaction, receipts []*types.Receipt, randomness *types.Randomness) (*types.Block, error)

func (*MockEngine) Prepare

func (e *MockEngine) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error

func (*MockEngine) Seal

func (e *MockEngine) Seal(chain consensus.ChainHeaderReader, block *types.Block) error

func (*MockEngine) SetCallBacks

func (e *MockEngine) SetCallBacks(hasBadBlock func(common.Hash) bool,
	processBlock func(*types.Block, *state.StateDB) (types.Receipts, []*types.Log, uint64, error),
	validateState func(*types.Block, *state.StateDB, types.Receipts, uint64) error,
	onNewConsensusBlock func(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB)) error

SetCallBacks sets call back functions

func (*MockEngine) VerifyHeader

func (e *MockEngine) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error

func (*MockEngine) VerifyHeaders

func (e *MockEngine) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error)

VerifyHeaders is similar to VerifyHeader, but verifies a batch of headers concurrently. The method returns a quit channel to abort the operations and a results channel to retrieve the async verifications.

func (*MockEngine) VerifySeal

func (e *MockEngine) VerifySeal(header *types.Header) error

type MockP2PServer

type MockP2PServer struct {
	Node *enode.Node
}

func NewMockP2PServer

func NewMockP2PServer(pubKey *ecdsa.PublicKey) *MockP2PServer

func (*MockP2PServer) AddPeer

func (serv *MockP2PServer) AddPeer(node *enode.Node, purpose p2p.PurposeFlag)

func (*MockP2PServer) AddTrustedPeer

func (serv *MockP2PServer) AddTrustedPeer(node *enode.Node, purpose p2p.PurposeFlag)

func (*MockP2PServer) RemovePeer

func (serv *MockP2PServer) RemovePeer(node *enode.Node, purpose p2p.PurposeFlag)

func (*MockP2PServer) RemoveTrustedPeer

func (serv *MockP2PServer) RemoveTrustedPeer(node *enode.Node, purpose p2p.PurposeFlag)

func (*MockP2PServer) Self

func (serv *MockP2PServer) Self() *enode.Node

type MockPeer

type MockPeer struct {
	// contains filtered or unexported fields
}

func NewMockPeer

func NewMockPeer(node *enode.Node, purposes p2p.PurposeFlag) *MockPeer

func (*MockPeer) Inbound

func (mp *MockPeer) Inbound() bool

func (*MockPeer) Node

func (mp *MockPeer) Node() *enode.Node

func (*MockPeer) PurposeIsSet

func (mp *MockPeer) PurposeIsSet(purpose p2p.PurposeFlag) bool

func (*MockPeer) ReadMsg

func (mp *MockPeer) ReadMsg() (p2p.Msg, error)

func (*MockPeer) Send

func (mp *MockPeer) Send(msgCode uint64, data interface{}) error

func (*MockPeer) Version

func (mp *MockPeer) Version() uint

type Mode

type Mode uint
const (
	Fake Mode = iota
	FullFake
)

Jump to

Keyboard shortcuts

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