mocks

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockVersion231 define block version 2310
	BlockVersion231 uint32 = 2030100
	// BlockVersion232 define block version 2320
	BlockVersion232 uint32 = 2030200
)

Variables

This section is empty.

Functions

func PutContractBytecodeIntoStore

func PutContractBytecodeIntoStore(store *BlockchainStoreMock, name string, bytecode []byte)

PutContractBytecodeIntoStore put contract bytecode into blockchain store

func PutContractIdIntoStore

func PutContractIdIntoStore(store *BlockchainStoreMock, name string, pbContract *commonPb.Contract) error

PutContractIdIntoStore put contract object into blockchain store

Types

type BlockchainStoreMock

type BlockchainStoreMock struct {
	sync.RWMutex

	Cache map[string][]byte
	// contains filtered or unexported fields
}

BlockchainStoreMock mock a BlockchainStore interface

func NewBlockchainStore

func NewBlockchainStore() *BlockchainStoreMock

NewBlockchainStore create a blockchain store object

func (*BlockchainStoreMock) ArchiveBlock

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

ArchiveBlock implements interface

func (*BlockchainStoreMock) BeginDbTransaction

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

BeginDbTransaction implements interface

func (*BlockchainStoreMock) BlockExists

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

BlockExists implements interface

func (*BlockchainStoreMock) Close

func (b *BlockchainStoreMock) Close() error

Close implements interface

func (*BlockchainStoreMock) CommitDbTransaction

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

CommitDbTransaction implements interface

func (*BlockchainStoreMock) CreateDatabase

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

CreateDatabase implements interface

func (*BlockchainStoreMock) DoHotColdDataSeparation

func (b *BlockchainStoreMock) DoHotColdDataSeparation(startHeight uint64, endHeight uint64) (string, error)

DoHotColdDataSeparation do something unknown

func (*BlockchainStoreMock) DropDatabase

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

DropDatabase implements interface

func (*BlockchainStoreMock) ExecDdlSql

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

ExecDdlSql implements interface

func (*BlockchainStoreMock) GetAccountTxHistory

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

GetAccountTxHistory implements interface

func (*BlockchainStoreMock) GetArchiveStatus

func (b *BlockchainStoreMock) GetArchiveStatus() (*store.ArchiveStatus, error)

GetArchiveStatus mock a BlockchainStore interface

func (*BlockchainStoreMock) GetArchivedPivot

func (b *BlockchainStoreMock) GetArchivedPivot() uint64

GetArchivedPivot implements interface

func (*BlockchainStoreMock) GetBlock

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

GetBlock implements interface

func (*BlockchainStoreMock) GetBlockByHash

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

GetBlockByHash implements interface

func (*BlockchainStoreMock) GetBlockByTx

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

GetBlockByTx implements interface

func (*BlockchainStoreMock) GetBlockHeaderByHeight

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

GetBlockHeaderByHeight implements interface

func (*BlockchainStoreMock) GetBlockWithRWSets

func (b *BlockchainStoreMock) GetBlockWithRWSets(height uint64) (*store.BlockWithRWSet, error)

GetBlockWithRWSets implements interface

func (*BlockchainStoreMock) GetContractByName

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

GetContractByName implements interface

func (*BlockchainStoreMock) GetContractBytecode

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

GetContractBytecode implements interface

func (*BlockchainStoreMock) GetContractDbName

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

GetContractDbName implements interface

func (*BlockchainStoreMock) GetContractTxHistory

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

GetContractTxHistory implements interface

func (*BlockchainStoreMock) GetDBHandle

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

GetDBHandle implements interface

func (*BlockchainStoreMock) GetDbTransaction

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

GetDbTransaction get db transaction

func (*BlockchainStoreMock) GetHeightByHash

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

GetHeightByHash implements interface

func (*BlockchainStoreMock) GetHistoryForKey

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

GetHistoryForKey implements interface

func (*BlockchainStoreMock) GetHotColdDataSeparationJobByID

func (b *BlockchainStoreMock) GetHotColdDataSeparationJobByID(jobID string) (store.ArchiveJob, error)

GetHotColdDataSeparationJobByID return something unknown

func (*BlockchainStoreMock) GetHotColdDataSeparationMaxHeight

func (b *BlockchainStoreMock) GetHotColdDataSeparationMaxHeight() (uint64, error)

GetHotColdDataSeparationMaxHeight return something unknown

func (*BlockchainStoreMock) GetLastBlock

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

GetLastBlock implements interface

func (*BlockchainStoreMock) GetLastChainConfig

func (b *BlockchainStoreMock) GetLastChainConfig() (*config.ChainConfig, error)

GetLastChainConfig implements interface

func (*BlockchainStoreMock) GetLastConfigBlock

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

GetLastConfigBlock implements interface

func (*BlockchainStoreMock) GetLastHeight

func (b *BlockchainStoreMock) GetLastHeight() (uint64, error)

GetLastHeight return a height of blockchain

func (*BlockchainStoreMock) GetMemberExtraData

func (b *BlockchainStoreMock) GetMemberExtraData(member *pbac.Member) (*pbac.MemberExtraData, error)

GetMemberExtraData implements interface

func (*BlockchainStoreMock) GetSnapshotStatus

func (b *BlockchainStoreMock) GetSnapshotStatus() uint64

GetSnapshotStatus return a status of snapshot

func (*BlockchainStoreMock) GetTx

GetTx implements interface

func (*BlockchainStoreMock) GetTxConfirmedTime

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

GetTxConfirmedTime implements interface

func (*BlockchainStoreMock) GetTxHeight

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

GetTxHeight implements interface

func (*BlockchainStoreMock) GetTxInfoOnly

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

GetTxInfoOnly implements interface

func (*BlockchainStoreMock) GetTxInfoWithRWSet

func (b *BlockchainStoreMock) GetTxInfoWithRWSet(txId string) (*commonPb.TransactionInfoWithRWSet, error)

GetTxInfoWithRWSet implements interface

func (*BlockchainStoreMock) GetTxRWSet

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

GetTxRWSet implements interface

func (*BlockchainStoreMock) GetTxRWSetsByHeight

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

GetTxRWSetsByHeight implements interface

func (*BlockchainStoreMock) GetTxWithInfo

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

GetTxWithInfo implements interface

func (*BlockchainStoreMock) GetTxWithRWSet

func (b *BlockchainStoreMock) GetTxWithRWSet(txId string) (*commonPb.TransactionWithRWSet, error)

GetTxWithRWSet implements interface

func (*BlockchainStoreMock) InitGenesis

func (b *BlockchainStoreMock) InitGenesis(genesisBlock *store.BlockWithRWSet) error

InitGenesis implements interface

func (*BlockchainStoreMock) MakeSnapshot

func (b *BlockchainStoreMock) MakeSnapshot(snapshotHeight uint64) error

MakeSnapshot make a snapshot

func (*BlockchainStoreMock) PrintDebugInfo

func (b *BlockchainStoreMock) PrintDebugInfo()

PrintDebugInfo implements interface

func (*BlockchainStoreMock) PutBlock

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

PutBlock implements interface

func (*BlockchainStoreMock) QueryMulti

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

QueryMulti implements interface

func (*BlockchainStoreMock) QuerySingle

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

QuerySingle implements interface

func (*BlockchainStoreMock) ReadObject

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

ReadObject implements interface

func (*BlockchainStoreMock) ReadObjects

func (b *BlockchainStoreMock) ReadObjects(string, [][]byte) ([][]byte, error)

ReadObjects read objects indexed by keys

func (*BlockchainStoreMock) RestoreBlocks

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

RestoreBlocks implements interface

func (*BlockchainStoreMock) RollbackDbTransaction

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

RollbackDbTransaction implements interface

func (*BlockchainStoreMock) SelectObject

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

SelectObject implements interface

func (*BlockchainStoreMock) TxExists

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

TxExists implements interface

func (*BlockchainStoreMock) TxExistsInFullDB

func (b *BlockchainStoreMock) TxExistsInFullDB(string) (bool, uint64, error)

TxExistsInFullDB implements interface

func (*BlockchainStoreMock) TxExistsInIncrementDB

func (b *BlockchainStoreMock) TxExistsInIncrementDB(txId string, startHeight uint64) (bool, error)

TxExistsInIncrementDB implements interface

func (*BlockchainStoreMock) TxExistsInIncrementDBState

func (b *BlockchainStoreMock) TxExistsInIncrementDBState(txId string, startHeight uint64) (bool, bool, error)

TxExistsInIncrementDBState implements interface

type SnapshotMock

type SnapshotMock struct {
	Store *BlockchainStoreMock

	LastChainConfig *config.ChainConfig
	// contains filtered or unexported fields
}

SnapshotMock mock a Snapshot interface

func (SnapshotMock) ApplyBlock

func (s SnapshotMock) ApplyBlock(block *commonPb.Block, txRWSetMap map[string]*commonPb.TxRWSet)

ApplyBlock implements interface

func (SnapshotMock) ApplyTxSimContext

func (s SnapshotMock) ApplyTxSimContext(
	context protocol.TxSimContext, txType protocol.ExecOrderTxType, b bool, b2 bool) (bool, int)

ApplyTxSimContext implements interface

func (SnapshotMock) BuildDAG

func (s SnapshotMock) BuildDAG(isSql bool, txRWSetTable []*commonPb.TxRWSet) *commonPb.DAG

BuildDAG implements interface

func (SnapshotMock) GetBlockFingerprint

func (s SnapshotMock) GetBlockFingerprint() string

GetBlockFingerprint implements interface

func (SnapshotMock) GetBlockHeight

func (s SnapshotMock) GetBlockHeight() uint64

GetBlockHeight implements interface

func (SnapshotMock) GetBlockProposer

func (s SnapshotMock) GetBlockProposer() *accessPb.Member

GetBlockProposer implements interface

func (SnapshotMock) GetBlockTimestamp

func (s SnapshotMock) GetBlockTimestamp() int64

GetBlockTimestamp implements interface

func (SnapshotMock) GetBlockchainStore

func (s SnapshotMock) GetBlockchainStore() protocol.BlockchainStore

GetBlockchainStore implements interface

func (SnapshotMock) GetKey

func (s SnapshotMock) GetKey(txExecSeq int, contractName string, key []byte) ([]byte, error)

GetKey implements interface

func (SnapshotMock) GetKeys

func (s SnapshotMock) GetKeys(txExecSeq int, keys []*vmPb.BatchKey) ([]*vmPb.BatchKey, error)

GetKeys implements interface

func (SnapshotMock) GetLastChainConfig

func (s SnapshotMock) GetLastChainConfig() *config.ChainConfig

GetLastChainConfig implements interface

func (SnapshotMock) GetPreSnapshot

func (s SnapshotMock) GetPreSnapshot() protocol.Snapshot

GetPreSnapshot implements interface

func (SnapshotMock) GetSnapshotSize

func (s SnapshotMock) GetSnapshotSize() int

GetSnapshotSize implements interface

func (SnapshotMock) GetSpecialTxTable

func (s SnapshotMock) GetSpecialTxTable() []*commonPb.Transaction

GetSpecialTxTable implements interface

func (SnapshotMock) GetTxRWSetTable

func (s SnapshotMock) GetTxRWSetTable() []*commonPb.TxRWSet

GetTxRWSetTable implements interface

func (SnapshotMock) GetTxResultMap

func (s SnapshotMock) GetTxResultMap() map[string]*commonPb.Result

GetTxResultMap implements interface

func (SnapshotMock) GetTxTable

func (s SnapshotMock) GetTxTable() []*commonPb.Transaction

GetTxTable implements interface

func (SnapshotMock) IsSealed

func (s SnapshotMock) IsSealed() bool

IsSealed implements interface

func (SnapshotMock) Seal

func (s SnapshotMock) Seal()

Seal implements interface

func (SnapshotMock) SetPreSnapshot

func (s SnapshotMock) SetPreSnapshot(snapshot protocol.Snapshot)

SetPreSnapshot implements interface

type VmManagerMock

type VmManagerMock struct {
	ChainId          string
	InstanceManagers map[commonPb.RuntimeType]protocol.VmInstancesManager
	Logger           protocol.Logger
	Ac               protocol.AccessControlProvider
}

VmManagerMock mock a VmManager interface

func (VmManagerMock) AfterSchedule

func (v VmManagerMock) AfterSchedule(blockFingerprint string, blockHeight uint64)

AfterSchedule implements interface

func (VmManagerMock) BeforeSchedule

func (v VmManagerMock) BeforeSchedule(blockFingerprint string, blockHeight uint64)

BeforeSchedule implements interface

func (VmManagerMock) GetAccessControl

func (v VmManagerMock) GetAccessControl() protocol.AccessControlProvider

GetAccessControl implements interface

func (VmManagerMock) GetChainNodesInfoProvider

func (v VmManagerMock) GetChainNodesInfoProvider() protocol.ChainNodesInfoProvider

GetChainNodesInfoProvider implements interface

func (VmManagerMock) GetConsensusStateWrapper

func (v VmManagerMock) GetConsensusStateWrapper() protocol.ConsensusStateWrapper

GetConsensusStateWrapper return consensus state wrapper

func (VmManagerMock) OnMessage

func (v VmManagerMock) OnMessage(message *msgbus.Message)

OnMessage on message

func (VmManagerMock) OnQuit

func (v VmManagerMock) OnQuit()

OnQuit on quit

func (VmManagerMock) RunContract

func (v VmManagerMock) RunContract(
	contract *commonPb.Contract, method string, byteCode []byte,
	parameters map[string][]byte, txContext protocol.TxSimContext,
	gasUsed uint64, refTxType commonPb.TxType) (
	contractResult *commonPb.ContractResult, specialTxType protocol.ExecOrderTxType, code commonPb.TxStatusCode)

RunContract implements interface

func (VmManagerMock) Start

func (v VmManagerMock) Start() error

Start implements interface

func (VmManagerMock) Stop

func (v VmManagerMock) Stop() error

Stop implements interface

Jump to

Keyboard shortcuts

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