Documentation ¶
Index ¶
- Constants
- func NewMockChain() iblockchain.BlockChain
- type FakeChains
- func (fc *FakeChains) GetLastPath(shardIndex shard.Index) *merkle.MerklePath
- func (fc *FakeChains) GetLedgerInfo(index shard.Index) *wire.LedgerInfo
- func (fc *FakeChains) GetNewBlock(shardIndex shard.Index, txps ...*wire.MsgTxWithProofs) *wire.MsgBlock
- func (fc *FakeChains) GetNewTx(shardIndex shard.Index, txType string, params interface{}, ...) *wire.MsgTxWithProofs
- func (fc *FakeChains) GetOutPath(shard shard.Index, out *wire.OutPoint) (*merkle.MerklePath, error)
- func (fc *FakeChains) GetState(shard shard.Index) (state.ShardStateManager, error)
- func (fc *FakeChains) Next(shard shard.Index, to multivacaddress.Address, amount *big.Int) *wire.MsgBlock
- type MockChain
- func (chain *MockChain) GetShardsBlockByHash(headerHash chainhash.Hash) *wire.MsgBlock
- func (chain *MockChain) GetShardsBlockByHeight(shardIndex shard.Index, hgt wire.BlockHeight) *wire.MsgBlock
- func (chain *MockChain) GetShardsHeaderByHash(headerHash chainhash.Hash) *wire.BlockHeader
- func (chain *MockChain) GetShardsHeaderByHeight(shardIndex shard.Index, hgt wire.BlockHeight) *wire.BlockHeader
- func (chain *MockChain) GetShardsHeaderHashes(shardIndex shard.Index, fromHgt wire.BlockHeight, toHgt wire.BlockHeight) []chainhash.Hash
- func (chain *MockChain) GetShardsHeight(shardIndex shard.Index) wire.BlockHeight
- func (chain *MockChain) GetSlimBlock(toshard shard.Index, shardIndex shard.Index, hgt wire.BlockHeight) *wire.SlimBlock
- func (chain *MockChain) GetSmartContract(addr multivacaddress.Address) *wire.SmartContract
- func (chain *MockChain) GetSmartContractCodeOut(contractAddr multivacaddress.Address, shardIdx shard.Index) *wire.OutState
- func (chain *MockChain) GetSmartContractShardInitOut(contractAddr multivacaddress.Address, shardIdx shard.Index) *wire.OutState
- func (chain *MockChain) ReceiveBlock(block *wire.MsgBlock) bool
- func (chain *MockChain) ReceiveHeader(header *wire.BlockHeader) bool
- func (chain *MockChain) ReceiveSlimBlock(msg *wire.SlimBlock) bool
- func (chain *MockChain) ReceiveSmartContractShardInitOut(out *wire.OutState) error
- func (chain *MockChain) SetSyncTrigger(shard shard.Index, trigger chain.SyncTrigger)
- type MockHeart
- func (mh *MockHeart) CheckConfirmation(msg *wire.MsgBlockConfirmation) bool
- func (mh *MockHeart) Has(pk []byte) bool
- func (mh *MockHeart) PerceivedCount() int
- func (mh *MockHeart) Receive(msg *wire.HeartBeatMsg)
- func (mh *MockHeart) SetNumberOfList(n int)
- func (mh *MockHeart) Start()
- func (mh *MockHeart) Stop()
Constants ¶
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
type MockChain ¶
type MockChain struct {
// contains filtered or unexported fields
}
MockChain used to facility deposit test
func (*MockChain) GetShardsBlockByHash ¶
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 ¶
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 ¶
ReceiveSlimBlock receives slimBlock and puts it into db.
func (*MockChain) ReceiveSmartContractShardInitOut ¶
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 ¶
NewMockHeart returns a new instance of MockHeart
func (*MockHeart) CheckConfirmation ¶
func (mh *MockHeart) CheckConfirmation(msg *wire.MsgBlockConfirmation) bool
CheckConfirmation implements HeatBeat interface.
func (*MockHeart) PerceivedCount ¶
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 ¶
SetNumberOfList just used for testing