Documentation ¶
Index ¶
- Variables
- func AppendCommitedSealByPkKeys(header *types.Header, pks []*ecdsa.PrivateKey)
- func AppendCommittedSeal(header *types.Header, committedSeal []byte)
- func AppendSeal(header *types.Header, be tendermint.Backend)
- func AppendSealByPkKey(header *types.Header, pk *ecdsa.PrivateKey)
- func GeneratePrivateKey() (*ecdsa.PrivateKey, error)
- func GetAddress() common.Address
- func MakeBlockWithSeal(be tendermint.Backend, pHeader *types.Header) *types.Block
- func MakeBlockWithoutSeal(pHeader *types.Header) *types.Block
- func MakeGenesisHeader(validators []common.Address) *types.Header
- func MakeNodeKey() *ecdsa.PrivateKey
- func MustCreateAndStartNewBackend(t *testing.T, nodePrivateKey *ecdsa.PrivateKey, genesisHeader *types.Header, ...) (tendermint.Backend, *core.TxPool)
- func MustCreateStateDB(t *testing.T) *state.StateDB
- func MustGeneratePrivateKey(key string) *ecdsa.PrivateKey
- func MustMakeBlockWithCommittedSeal(be tendermint.Backend, pHeader *types.Header) *types.Block
- func MustMakeBlockWithCommittedSealInvalid(be tendermint.Backend, pHeader *types.Header) *types.Block
- func NewHeadersMockChainReader(headers []*types.Header) consensus.ChainReader
- func NewMockBackend(privateKey *ecdsa.PrivateKey, blockchain *MockChainReader, ...) tendermint.Backend
- func PrepareExtra(header *types.Header) ([]byte, error)
- type MockBackend
- func (mb *MockBackend) Address() common.Address
- func (mb *MockBackend) Broadcast(valSet tendermint.ValidatorSet, blockNumber *big.Int, round int64, ...) error
- func (mb *MockBackend) Cancel(block *types.Block)
- func (mb *MockBackend) Commit(block *types.Block)
- func (mb *MockBackend) CurrentHeadBlock() *types.Block
- func (mb *MockBackend) EventMux() *event.TypeMux
- func (mb *MockBackend) FindExistingPeers(valSet tendermint.ValidatorSet) map[common.Address]consensus.Peer
- func (mb *MockBackend) Gossip(valSet tendermint.ValidatorSet, _ *big.Int, _ int64, _ uint64, payload []byte) error
- func (mb *MockBackend) Multicast(targets map[common.Address]bool, payload []byte) error
- func (mb *MockBackend) Sign(data []byte) ([]byte, error)
- func (mb *MockBackend) Validators(blockNumber *big.Int) tendermint.ValidatorSet
- func (mb *MockBackend) VerifyProposalBlock(block *types.Block) error
- func (mb *MockBackend) VerifyProposalHeader(header *types.Header) error
- type MockBlockChain
- func (bc *MockBlockChain) CurrentBlock() *types.Block
- func (bc *MockBlockChain) GetBlock(hash common.Hash, number uint64) *types.Block
- func (bc *MockBlockChain) StateAt(common.Hash) (*state.StateDB, error)
- func (bc *MockBlockChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
- type MockChainReader
- func (c *MockChainReader) Config() *params.ChainConfig
- func (c *MockChainReader) CurrentHeader() *types.Header
- func (c *MockChainReader) GetHeader(hash common.Hash, blockNumber uint64) *types.Header
- func (c *MockChainReader) GetHeaderByHash(hash common.Hash) *types.Header
- func (c *MockChainReader) GetHeaderByNumber(blockNumber uint64) *types.Header
- func (c *MockChainReader) State() (*state.StateDB, error)
- type MockPeer
- type MockProtocolManager
- type SentMsgEvent
Constants ¶
This section is empty.
Variables ¶
var DefaultTestConfig = &tendermint.Config{ ProposerPolicy: tendermint.RoundRobin, Epoch: 30000, BlockPeriod: 1, TimeoutPropose: 30 * time.Millisecond, TimeoutProposeDelta: 50 * time.Millisecond, TimeoutPrevote: 100 * time.Millisecond, TimeoutPrevoteDelta: 50 * time.Millisecond, TimeoutPrecommit: 100 * time.Millisecond, TimeoutPrecommitDelta: 50 * time.Millisecond, TimeoutCommit: 100 * time.Millisecond, FaultyMode: tendermint.Disabled.Uint64(), }
DefaultTestConfig with time is smaller than DefaultConfig for speed-up
Functions ¶
func AppendCommitedSealByPkKeys ¶
func AppendCommitedSealByPkKeys(header *types.Header, pks []*ecdsa.PrivateKey)
func AppendCommittedSeal ¶
AppendCommittedSeal
func AppendSeal ¶
func AppendSeal(header *types.Header, be tendermint.Backend)
AppendSeal sign the header with the engine's key and write the seal to the input header's extra data
func AppendSealByPkKey ¶
func AppendSealByPkKey(header *types.Header, pk *ecdsa.PrivateKey)
func GeneratePrivateKey ¶
func GeneratePrivateKey() (*ecdsa.PrivateKey, error)
func GetAddress ¶
func MakeBlockWithSeal ¶
func MakeNodeKey ¶
func MakeNodeKey() *ecdsa.PrivateKey
func MustGeneratePrivateKey ¶
func MustGeneratePrivateKey(key string) *ecdsa.PrivateKey
func NewHeadersMockChainReader ¶
func NewHeadersMockChainReader(headers []*types.Header) consensus.ChainReader
func NewMockBackend ¶
func NewMockBackend(privateKey *ecdsa.PrivateKey, blockchain *MockChainReader, validators []common.Address) tendermint.Backend
Types ¶
type MockBackend ¶
type MockBackend struct { // SendEventMux is used for receiving output msg from core SendEventMux *event.TypeMux // contains filtered or unexported fields }
func (*MockBackend) Address ¶
func (mb *MockBackend) Address() common.Address
Address implements tendermint.Backend.Address
func (*MockBackend) Broadcast ¶
func (mb *MockBackend) Broadcast(valSet tendermint.ValidatorSet, blockNumber *big.Int, round int64, msgType uint64, payload []byte) error
Broadcast implements tendermint.Backend.Broadcast It sends message to its validator by calling gossiping, and send message to itself by eventMux
func (*MockBackend) Cancel ¶
func (mb *MockBackend) Cancel(block *types.Block)
func (*MockBackend) Commit ¶
func (mb *MockBackend) Commit(block *types.Block)
Commit implement tendermint.Backend.Commit()
func (*MockBackend) CurrentHeadBlock ¶
func (mb *MockBackend) CurrentHeadBlock() *types.Block
func (*MockBackend) EventMux ¶
func (mb *MockBackend) EventMux() *event.TypeMux
EventMux implements tendermint.Backend.EventMux
func (*MockBackend) FindExistingPeers ¶
func (mb *MockBackend) FindExistingPeers(valSet tendermint.ValidatorSet) map[common.Address]consensus.Peer
FindExistingPeers check validator peers exist or not by address
func (*MockBackend) Gossip ¶
func (mb *MockBackend) Gossip(valSet tendermint.ValidatorSet, _ *big.Int, _ int64, _ uint64, payload []byte) error
Gossip implements tendermint.Backend.Gossip It sends message to its validators only, not itself. The validators must be able to connected through Peer. It will return MockBackend.ErrNoBroadcaster if no broadcaster is set for MockBackend
func (*MockBackend) Sign ¶
func (mb *MockBackend) Sign(data []byte) ([]byte, error)
Sign implements tendermint.Backend.Sign
func (*MockBackend) Validators ¶
func (mb *MockBackend) Validators(blockNumber *big.Int) tendermint.ValidatorSet
Validators return validator set for a block number TODO: revise this function once auth vote is implemented
func (*MockBackend) VerifyProposalBlock ¶
func (mb *MockBackend) VerifyProposalBlock(block *types.Block) error
func (*MockBackend) VerifyProposalHeader ¶
func (mb *MockBackend) VerifyProposalHeader(header *types.Header) error
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) SubscribeChainHeadEvent ¶
func (bc *MockBlockChain) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription
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 (*MockChainReader) Config ¶
func (c *MockChainReader) Config() *params.ChainConfig
func (*MockChainReader) CurrentHeader ¶
func (c *MockChainReader) CurrentHeader() *types.Header
func (*MockChainReader) GetHeader ¶
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
type MockPeer ¶
type MockPeer struct {
SendFn func(data interface{}) error
}
MockPeer implements consensus/protocol/Peers
type MockProtocolManager ¶
type MockProtocolManager struct{}
type SentMsgEvent ¶
SentMsgEvent represents an action send to an peer