testutil

package
v0.0.0-...-4f0ab6e Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2021 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Deposit = "deposit"
)

Package name for testing

Variables

This section is empty.

Functions

func NewMockChain

func NewMockChain() iblockchain.BlockChain

NewMockChain returns the new instance of MockChain

Types

type FakeChains

type FakeChains struct {
	ShardHeight map[shard.Index]int64
	Chains      map[shard.Index]*fakeChain
	// contains filtered or unexported fields
}

FakeChains is a fake abci used for testing

func NewFakeChains

func NewFakeChains(t *testing.T, blockchain iblockchain.BlockChain) *FakeChains

NewFakeChains returns the new instance of fake abci

func (*FakeChains) GetLastPath

func (fc *FakeChains) GetLastPath(shardIndex shard.Index) *merkle.MerklePath

GetLastPath Returns the last path of the ledger tree for given shard.

func (*FakeChains) GetLedgerInfo

func (fc *FakeChains) GetLedgerInfo(index shard.Index) *wire.LedgerInfo

GetLedgerInfo Returns a LedgerInfo struct contains the current height of each shard and total size.

func (*FakeChains) GetNewBlock

func (fc *FakeChains) GetNewBlock(shardIndex shard.Index, txps ...*wire.MsgTxWithProofs) *wire.MsgBlock

GetNewBlock returns a new block of a shard

func (*FakeChains) GetNewTx

func (fc *FakeChains) GetNewTx(shardIndex shard.Index, txType string, params interface{}, out ...*wire.OutPoint) *wire.MsgTxWithProofs

GetNewTx Generate a Tx with proofs. The inputs will be deleted immediately form the fake chains.

func (*FakeChains) GetOutPath

func (fc *FakeChains) GetOutPath(shard shard.Index, out *wire.OutPoint) (*merkle.MerklePath, error)

GetOutPath get an out's merkle path

func (*FakeChains) GetState

func (fc *FakeChains) GetState(shard shard.Index) (state.ShardStateManager, error)

GetState get update from fakechain

func (*FakeChains) Next

func (fc *FakeChains) Next(shard shard.Index, to multivacaddress.Address, amount *big.Int) *wire.MsgBlock

Next used to gererate a new block on the current chain It usually used to confirm the last block

type MockChain

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

MockChain used to facility deposit test

func (*MockChain) GetShardsBlockByHash

func (chain *MockChain) GetShardsBlockByHash(headerHash chainhash.Hash) *wire.MsgBlock

GetShardsBlockByHash returns a block according to the header hash.

func (*MockChain) GetShardsBlockByHeight

func (chain *MockChain) GetShardsBlockByHeight(shardIndex shard.Index, hgt wire.BlockHeight) *wire.MsgBlock

GetShardsBlockByHeight returns a block according to the shard and height.

func (*MockChain) GetShardsHeaderByHash

func (chain *MockChain) GetShardsHeaderByHash(headerHash chainhash.Hash) *wire.BlockHeader

GetShardsHeaderByHash returns a header accroding to header hash.

func (*MockChain) GetShardsHeaderByHeight

func (chain *MockChain) GetShardsHeaderByHeight(shardIndex shard.Index, hgt wire.BlockHeight) *wire.BlockHeader

GetShardsHeaderByHeight returns a header according to the shard and height.

func (*MockChain) GetShardsHeaderHashes

func (chain *MockChain) GetShardsHeaderHashes(shardIndex shard.Index, fromHgt wire.BlockHeight, toHgt wire.BlockHeight) []chainhash.Hash

GetShardsHeaderHashes returns the header hash according to shard index.

func (*MockChain) GetShardsHeight

func (chain *MockChain) GetShardsHeight(shardIndex shard.Index) wire.BlockHeight

GetShardsHeight returns the height of the shard.

func (*MockChain) GetSlimBlock

func (chain *MockChain) GetSlimBlock(toshard shard.Index, shardIndex shard.Index, hgt wire.BlockHeight) *wire.SlimBlock

GetSlimBlock returns slimblock by shard index and height.

func (*MockChain) GetSmartContract

func (chain *MockChain) GetSmartContract(addr multivacaddress.Address) *wire.SmartContract

GetSmartContract returns smart-contract data from db.

func (*MockChain) GetSmartContractCodeOut

func (chain *MockChain) GetSmartContractCodeOut(contractAddr multivacaddress.Address, shardIdx shard.Index) *wire.OutState

GetSmartContractCodeOut returns smart-contract out from db.

func (*MockChain) GetSmartContractShardInitOut

func (chain *MockChain) GetSmartContractShardInitOut(contractAddr multivacaddress.Address, shardIdx shard.Index) *wire.OutState

GetSmartContractShardInitOut returns data of smart-contract.

func (*MockChain) ReceiveBlock

func (chain *MockChain) ReceiveBlock(block *wire.MsgBlock) bool

ReceiveBlock receives a new block, no-op if it is not in the same shard

func (*MockChain) ReceiveHeader

func (chain *MockChain) ReceiveHeader(header *wire.BlockHeader) bool

ReceiveHeader receives header and puts it into db.

func (*MockChain) ReceiveSlimBlock

func (chain *MockChain) ReceiveSlimBlock(msg *wire.SlimBlock) bool

ReceiveSlimBlock receives slimBlock and puts it into db.

func (*MockChain) ReceiveSmartContractShardInitOut

func (chain *MockChain) ReceiveSmartContractShardInitOut(out *wire.OutState) error

ReceiveSmartContractShardInitOut puts smart-contract init data to db.

func (*MockChain) SetSyncTrigger

func (chain *MockChain) SetSyncTrigger(shard shard.Index, trigger chain.SyncTrigger)

SetSyncTrigger maybe unused now.

type MockHeart

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

MockHeart is heartbeat just used for testing

func NewMockHeart

func NewMockHeart(n int) *MockHeart

NewMockHeart returns a new instance of MockHeart

func (*MockHeart) CheckConfirmation

func (mh *MockHeart) CheckConfirmation(msg *wire.MsgBlockConfirmation) bool

CheckConfirmation implements HeatBeat interface.

func (*MockHeart) Has

func (mh *MockHeart) Has(pk []byte) bool

Has verfity if the pk is in whitelist

func (*MockHeart) PerceivedCount

func (mh *MockHeart) PerceivedCount() int

PerceivedCount returns the number of full network miners currently listening

func (*MockHeart) Receive

func (mh *MockHeart) Receive(msg *wire.HeartBeatMsg)

Receive used to receive heartbeat message from other nodes

func (*MockHeart) SetNumberOfList

func (mh *MockHeart) SetNumberOfList(n int)

SetNumberOfList just used for testing

func (*MockHeart) Start

func (mh *MockHeart) Start()

Start this module

func (*MockHeart) Stop

func (mh *MockHeart) Stop()

Stop this module

Jump to

Keyboard shortcuts

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