testframework

package
v0.0.0-...-7888d19 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Org1Path = "wx-org1.chainmaker.org"
	Org2Path = "wx-org2.chainmaker.org"
	Org3Path = "wx-org3.chainmaker.org"
	Org4Path = "wx-org4.chainmaker.org"
	Org5Path = "wx-org5.chainmaker.org"
	Org6Path = "wx-org6.chainmaker.org"
	Org7Path = "wx-org7.chainmaker.org"
)
View Source
const (
	LIMIT_DELIMITER = "/"
)

Variables

This section is empty.

Functions

func InitChainConfig

func InitChainConfig(chainId string, consensusType consensusPb.ConsensusType, nodeNum int) *configPb.ChainConfig

InitChainConfig

func InitLocalConfig

func InitLocalConfig(nodeNum int)

InitLocalConfig

func InitLocalConfigs

func InitLocalConfigs() error

InitLocalConfigs

func NewCache

func NewCache(chainId string) protocol.LedgerCache

NewLedgerCache get a ledger cache. One ledger cache for one chain.

func NewNetServiceForTest

func NewNetServiceForTest() protocol.NetService

####################################################################################################################

impls NetService for TBFT         (only use GetNodeUidByCertId() method)

#################################################################################################################### NewNetServiceForTest

func NewProposalCache

func NewProposalCache(chainConf protocol.ChainConf, ledgerCache protocol.LedgerCache) protocol.ProposalCache

NewProposalCache get a ProposalCache. One ProposalCache for one chain.

func RemoveLocalConfigs

func RemoveLocalConfigs()

RemoveLocalConfigs

func SetTxSizeAndTxNum

func SetTxSizeAndTxNum(size, num int)

SetTxSizeAndTxNum

Types

type BlockchainStoreForTest

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

BlockchainStoreForTest

func NewBlockChainStoreForTest

func NewBlockChainStoreForTest() *BlockchainStoreForTest

NewBlockChainStoreForTest

func (*BlockchainStoreForTest) ArchiveBlock

func (b *BlockchainStoreForTest) ArchiveBlock(archiveHeight uint64) error

ArchiveBlock

func (*BlockchainStoreForTest) BeginDbTransaction

func (b *BlockchainStoreForTest) BeginDbTransaction(txName string) (protocol.SqlDBTransaction, error)

BeginDbTransaction

func (*BlockchainStoreForTest) BlockExists

func (b *BlockchainStoreForTest) BlockExists(blockHash []byte) (bool, error)

BlockExists

func (*BlockchainStoreForTest) Close

func (b *BlockchainStoreForTest) Close() error

Close

func (*BlockchainStoreForTest) CommitDbTransaction

func (b *BlockchainStoreForTest) CommitDbTransaction(txName string) error

CommitDbTransaction

func (*BlockchainStoreForTest) CreateDatabase

func (b *BlockchainStoreForTest) CreateDatabase(contractName string) error

CreateDatabase

func (*BlockchainStoreForTest) DropDatabase

func (b *BlockchainStoreForTest) DropDatabase(contractName string) error

DropDatabase

func (*BlockchainStoreForTest) ExecDdlSql

func (b *BlockchainStoreForTest) ExecDdlSql(contractName, sql, version string) error

ExecDdlSql

func (*BlockchainStoreForTest) GetAccountTxHistory

func (b *BlockchainStoreForTest) GetAccountTxHistory(accountId []byte) (protocol.TxHistoryIterator, error)

GetAccountTxHistory

func (*BlockchainStoreForTest) GetArchivedPivot

func (b *BlockchainStoreForTest) GetArchivedPivot() uint64

GetArchivedPivot

func (*BlockchainStoreForTest) GetBlock

func (b *BlockchainStoreForTest) GetBlock(height uint64) (*commonPb.Block, error)

GetBlock

func (*BlockchainStoreForTest) GetBlockByHash

func (b *BlockchainStoreForTest) GetBlockByHash(blockHash []byte) (*commonPb.Block, error)

GetBlockByHash

func (*BlockchainStoreForTest) GetBlockByTx

func (b *BlockchainStoreForTest) GetBlockByTx(txId string) (*commonPb.Block, error)

GetBlockByTx

func (*BlockchainStoreForTest) GetBlockHeaderByHeight

func (b *BlockchainStoreForTest) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)

GetBlockHeaderByHeight

func (*BlockchainStoreForTest) GetBlockWithRWSets

func (b *BlockchainStoreForTest) GetBlockWithRWSets(height uint64) (*storePb.BlockWithRWSet, error)

GetBlockWithRWSets

func (*BlockchainStoreForTest) GetContractByName

func (b *BlockchainStoreForTest) GetContractByName(name string) (*commonPb.Contract, error)

GetContractByName

func (*BlockchainStoreForTest) GetContractBytecode

func (b *BlockchainStoreForTest) GetContractBytecode(name string) ([]byte, error)

GetContractBytecode

func (*BlockchainStoreForTest) GetContractDbName

func (b *BlockchainStoreForTest) GetContractDbName(contractName string) string

GetContractDbName

func (*BlockchainStoreForTest) GetContractTxHistory

func (b *BlockchainStoreForTest) GetContractTxHistory(contractName string) (protocol.TxHistoryIterator, error)

GetContractTxHistory

func (*BlockchainStoreForTest) GetDBHandle

func (b *BlockchainStoreForTest) GetDBHandle(dbName string) protocol.DBHandle

GetDBHandle

func (*BlockchainStoreForTest) GetDbTransaction

func (b *BlockchainStoreForTest) GetDbTransaction(txName string) (protocol.SqlDBTransaction, error)

GetDbTransaction

func (*BlockchainStoreForTest) GetHeightByHash

func (b *BlockchainStoreForTest) GetHeightByHash(blockHash []byte) (uint64, error)

GetHeightByHash

func (*BlockchainStoreForTest) GetHistoryForKey

func (b *BlockchainStoreForTest) GetHistoryForKey(contractName string,
	key []byte) (protocol.KeyHistoryIterator, error)

GetHistoryForKey

func (*BlockchainStoreForTest) GetLastBlock

func (b *BlockchainStoreForTest) GetLastBlock() (*commonPb.Block, error)

GetLastBlock

func (*BlockchainStoreForTest) GetLastChainConfig

func (b *BlockchainStoreForTest) GetLastChainConfig() (*configPb.ChainConfig, error)

GetLastChainConfig

func (*BlockchainStoreForTest) GetLastConfigBlock

func (b *BlockchainStoreForTest) GetLastConfigBlock() (*commonPb.Block, error)

GetLastConfigBlock

func (*BlockchainStoreForTest) GetMemberExtraData

func (b *BlockchainStoreForTest) GetMemberExtraData(
	member *accesscontrol.Member) (*accesscontrol.MemberExtraData, error)

GetMemberExtraData

func (*BlockchainStoreForTest) GetTx

GetTx

func (*BlockchainStoreForTest) GetTxConfirmedTime

func (b *BlockchainStoreForTest) GetTxConfirmedTime(txId string) (int64, error)

GetTxConfirmedTime

func (*BlockchainStoreForTest) GetTxHeight

func (b *BlockchainStoreForTest) GetTxHeight(txId string) (uint64, error)

GetTxHeight

func (*BlockchainStoreForTest) GetTxInfoOnly

func (b *BlockchainStoreForTest) GetTxInfoOnly(txId string) (*commonPb.TransactionInfo, error)

GetTxInfoOnly

func (*BlockchainStoreForTest) GetTxRWSet

func (b *BlockchainStoreForTest) GetTxRWSet(txId string) (*commonPb.TxRWSet, error)

GetTxRWSet

func (*BlockchainStoreForTest) GetTxRWSetsByHeight

func (b *BlockchainStoreForTest) GetTxRWSetsByHeight(height uint64) ([]*commonPb.TxRWSet, error)

GetTxRWSetsByHeight

func (*BlockchainStoreForTest) GetTxWithInfo

func (b *BlockchainStoreForTest) GetTxWithInfo(txId string) (*commonPb.TransactionInfo, error)

GetTxWithInfo

func (*BlockchainStoreForTest) InitGenesis

func (b *BlockchainStoreForTest) InitGenesis(genesisBlock *storePb.BlockWithRWSet) error

InitGenesis

func (*BlockchainStoreForTest) PutBlock

func (b *BlockchainStoreForTest) PutBlock(block *commonPb.Block, txRWSets []*commonPb.TxRWSet) error

PutBlock

func (*BlockchainStoreForTest) QueryMulti

func (b *BlockchainStoreForTest) QueryMulti(contractName, sql string, values ...interface{}) (protocol.SqlRows, error)

QueryMulti

func (*BlockchainStoreForTest) QuerySingle

func (b *BlockchainStoreForTest) QuerySingle(contractName, sql string, values ...interface{}) (protocol.SqlRow, error)

QuerySingle

func (*BlockchainStoreForTest) ReadObject

func (b *BlockchainStoreForTest) ReadObject(contractName string, key []byte) ([]byte, error)

ReadObject

func (*BlockchainStoreForTest) RestoreBlocks

func (b *BlockchainStoreForTest) RestoreBlocks(serializedBlocks [][]byte) error

RestoreBlocks

func (*BlockchainStoreForTest) RollbackDbTransaction

func (b *BlockchainStoreForTest) RollbackDbTransaction(txName string) error

RollbackDbTransaction

func (*BlockchainStoreForTest) SelectObject

func (b *BlockchainStoreForTest) SelectObject(contractName string,
	startKey []byte, limit []byte) (protocol.StateIterator, error)

SelectObject

func (*BlockchainStoreForTest) SetInitStates

func (b *BlockchainStoreForTest) SetInitStates(contractName, key string, val []byte)

SetInitStates

func (*BlockchainStoreForTest) TxExists

func (b *BlockchainStoreForTest) TxExists(txId string) (bool, error)

TxExists

type Cache

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

####################################################################################################################

impls LedgerCache          (avoid circular references to core module)

#################################################################################################################### Cache is used for cache current block info

func (*Cache) CurrentHeight

func (c *Cache) CurrentHeight() (uint64, error)

CurrentHeight get current block height

func (*Cache) GetLastCommittedBlock

func (c *Cache) GetLastCommittedBlock() *commonPb.Block

GetLastCommittedBlock get the latest committed block

func (*Cache) SetLastCommittedBlock

func (c *Cache) SetLastCommittedBlock(b *commonPb.Block)

SetLastCommittedBlock set the latest committed block

type ChainConfImplForTest

type ChainConfImplForTest struct {
	ChainConf *configPb.ChainConfig
	// contains filtered or unexported fields
}

####################################################################################################################

impls ChainConf interface

####################################################################################################################

func (*ChainConfImplForTest) AddVmWatch

func (cc *ChainConfImplForTest) AddVmWatch(w protocol.VmWatcher)

AddVmWatch

func (*ChainConfImplForTest) AddWatch

func (cc *ChainConfImplForTest) AddWatch(w protocol.Watcher)

AddWatch

func (*ChainConfImplForTest) ChainConfig

func (cc *ChainConfImplForTest) ChainConfig() *configPb.ChainConfig

ChainConfig

func (*ChainConfImplForTest) CompleteBlock

func (cc *ChainConfImplForTest) CompleteBlock(block *commonPb.Block) error

CompleteBlock

func (*ChainConfImplForTest) GetChainConfigAt

func (cc *ChainConfImplForTest) GetChainConfigAt(blockHeight uint64) (*configPb.ChainConfig, error)

GetChainConfigAt

func (*ChainConfImplForTest) GetChainConfigFromFuture

func (cc *ChainConfImplForTest) GetChainConfigFromFuture(blockHeight uint64) (*configPb.ChainConfig, error)

GetChainConfigFromFuture

func (*ChainConfImplForTest) GetConsensusNodeIdList

func (cc *ChainConfImplForTest) GetConsensusNodeIdList() ([]string, error)

GetConsensusNodeIdList

func (*ChainConfImplForTest) Init

func (cc *ChainConfImplForTest) Init() error

Init

type ConfigData

type ConfigData struct {
	Path string
	Data string
}

type CoreEngineForTest

type CoreEngineForTest struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCoreEngineForTest

func NewCoreEngineForTest(tnc *TestNodeConfig, log protocol.Logger) *CoreEngineForTest

NewCoreEngineForTest

func (*CoreEngineForTest) CalcTime

func (ce *CoreEngineForTest) CalcTime()

CalcTime

func (*CoreEngineForTest) GetBlockCommitter

func (ce *CoreEngineForTest) GetBlockCommitter() protocol.BlockCommitter

GetBlockCommitter

func (*CoreEngineForTest) GetBlockVerifier

func (ce *CoreEngineForTest) GetBlockVerifier() protocol.BlockVerifier

GetBlockVerifier

func (*CoreEngineForTest) GetHotStuffHelper

func (ce *CoreEngineForTest) GetHotStuffHelper() protocol.MaxbftHelper

GetHotStuffHelper

func (*CoreEngineForTest) GetMaxbftHelper

func (ce *CoreEngineForTest) GetMaxbftHelper() protocol.MaxbftHelper

GetMaxbftHelper

func (*CoreEngineForTest) OnMessage

func (ce *CoreEngineForTest) OnMessage(message *msgbus.Message)

OnMessage

func (*CoreEngineForTest) OnQuit

func (ce *CoreEngineForTest) OnQuit()

OnQuit

func (*CoreEngineForTest) Start

func (ce *CoreEngineForTest) Start()

Start

func (*CoreEngineForTest) Stop

func (ce *CoreEngineForTest) Stop()

Stop

type GetConsensusArg

type GetConsensusArg func(cfg *configPb.ChainConfig) []byte

GetConsensusArg

type MaxbftHelper

type MaxbftHelper struct{}

func (*MaxbftHelper) DiscardAboveHeight

func (mh *MaxbftHelper) DiscardAboveHeight(baseHeight uint64)

DiscardAboveHeight

type NetEngineForTest

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

####################################################################################################################

Net Engine

####################################################################################################################

func NewNetEngineForTest

func NewNetEngineForTest(chainId, nodeId string, msgBus msgbus.MessageBus, tf *TestClusterFramework) *NetEngineForTest

NewNetEngineForTest

func (*NetEngineForTest) OnMessage

func (ne *NetEngineForTest) OnMessage(message *msgbus.Message)

OnMessage

func (*NetEngineForTest) OnQuit

func (ne *NetEngineForTest) OnQuit()

OnQuit

func (*NetEngineForTest) Start

func (ne *NetEngineForTest) Start()

Start

func (*NetEngineForTest) Stop

func (ne *NetEngineForTest) Stop()

Stop

type ProposalCache

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

ProposalCache is used for cache proposal blocks

func (*ProposalCache) ClearProposedBlockAt

func (pc *ProposalCache) ClearProposedBlockAt(height uint64)

ClearProposedBlockAt clear proposed blocks with height.

func (*ProposalCache) ClearTheBlock

func (pc *ProposalCache) ClearTheBlock(block *commonpb.Block)

ClearTheBlock f

func (*ProposalCache) DiscardAboveHeight

func (pc *ProposalCache) DiscardAboveHeight(baseHeight uint64) []*commonpb.Block

func (*ProposalCache) GetProposedBlock

func (pc *ProposalCache) GetProposedBlock(b *commonpb.Block) (
	*commonpb.Block, map[string]*commonpb.TxRWSet, map[string][]*commonpb.ContractEvent)

GetProposedBlock get proposed block with specific block hash in current consensus height.

func (*ProposalCache) GetProposedBlockByHashAndHeight

func (pc *ProposalCache) GetProposedBlockByHashAndHeight(hash []byte, height uint64) (
	*commonpb.Block, map[string]*commonpb.TxRWSet)

GetProposedBlockByHashAndHeight get proposed block by block hash and block height.

func (*ProposalCache) GetProposedBlocksAt

func (pc *ProposalCache) GetProposedBlocksAt(height uint64) []*commonpb.Block

GetProposedBlocksAt get all proposed blocks at a specific height. It is possible that generate several proposal blocks in one height because of some unpredictable situation of consensus.

func (*ProposalCache) GetSelfProposedBlockAt

func (pc *ProposalCache) GetSelfProposedBlockAt(height uint64) *commonpb.Block

GetSelfProposedBlockAt get proposed block that is proposed by node itself.

func (*ProposalCache) HasProposedBlockAt

func (pc *ProposalCache) HasProposedBlockAt(height uint64) bool

HasProposedBlockAt return if a proposed block has cached in current consensus height.

func (*ProposalCache) IsProposedAt

func (pc *ProposalCache) IsProposedAt(height uint64) bool

IsProposedAt return if this node has proposed a block as proposer.

func (*ProposalCache) KeepProposedBlock

func (pc *ProposalCache) KeepProposedBlock(hash []byte, height uint64) []*commonpb.Block

Remove proposed block in height except the specific block.

func (*ProposalCache) ResetProposedAt

func (pc *ProposalCache) ResetProposedAt(height uint64)

ResetProposedAt reset propose status of this node.

func (*ProposalCache) SetProposedAt

func (pc *ProposalCache) SetProposedAt(height uint64)

SetProposedAt to mark this node has proposed a block as proposer.

func (*ProposalCache) SetProposedBlock

func (pc *ProposalCache) SetProposedBlock(b *commonpb.Block, rwSetMap map[string]*commonpb.TxRWSet,
	contractEventMap map[string][]*commonpb.ContractEvent, selfPropose bool) error

SetProposedBlock set porposed block in current consensus height, after it's generated or verified.

type TestClusterFramework

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

####################################################################################################################

Cluster Framework

####################################################################################################################

func NewTestClusterFramework

func NewTestClusterFramework(chainId string, consensusType consensusPb.ConsensusType,
	nodeNum int, tnc []*TestNodeConfig, consensusEngines []protocol.ConsensusEngine,
	coreEngines []protocol.CoreEngine) (*TestClusterFramework, error)

NewTestClusterFramework

func (*TestClusterFramework) Start

func (tf *TestClusterFramework) Start()

Start

func (*TestClusterFramework) Stop

func (tf *TestClusterFramework) Stop()

Stop

type TestNode

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

####################################################################################################################

Test Node

####################################################################################################################

func NewTestNode

NewTestNode

func (*TestNode) Start

func (tn *TestNode) Start()

Start

func (*TestNode) Stop

func (tn *TestNode) Stop()

Stop

type TestNodeConfig

type TestNodeConfig struct {
	ChainID         string
	NodeId          string
	ConsensusType   consensusPb.ConsensusType
	GenesisBlock    *commonPb.Block
	Signer          protocol.SigningMember
	Ac              protocol.AccessControlProvider
	LedgerCache     protocol.LedgerCache
	ChainConf       protocol.ChainConf
	MsgBus          msgbus.MessageBus
	BlockchainStore protocol.BlockchainStore
	ProposalCache   protocol.ProposalCache
}

TestNodeConfig

func CreateTestNodeConfig

func CreateTestNodeConfig(ctrl *gomock.Controller, nodeNum int, chainId string,
	consensusType consensus.ConsensusType, fn GetConsensusArg) ([]*TestNodeConfig, error)

CreateTestNodeConfig

Jump to

Keyboard shortcuts

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