test

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package test provides mock objects and utilities for testing tx_context.

Index

Constants

View Source
const (
	//ChainIdTest chain id test
	ChainIdTest = "chain01"
)

contract and chain info

Variables

View Source
var ByteCodeFile = "./test/contract01/token.bin"

ByteCodeFile byte code file path

View Source
var CertFilePath = "./config/admin1.sing.crt"

CertFilePath cert file path

View Source
var ContractName = "contract01"

ContractName for test

View Source
var ContractVersion = "v1.0.0"

ContractVersion for test

Functions

func BaseParam

func BaseParam(parameters map[string][]byte)

BaseParam base parameter

Types

type TxContextMockTest

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

TxContextMockTest simTxContext mock for ut

func InitContextTest

func InitContextTest(runtimeType commonPb.RuntimeType, t *testing.T) (*commonPb.Contract, *TxContextMockTest, []byte)

InitContextTest 初始化上下文和wasm字节码

func (*TxContextMockTest) CallContract

func (s *TxContextMockTest) CallContract(caller, contract *commonPb.Contract, method string, byteCode []byte,
	parameter map[string][]byte, gasUsed uint64, refTxType commonPb.TxType) (*commonPb.ContractResult,
	protocol.ExecOrderTxType, commonPb.TxStatusCode)

CallContract call contract

func (*TxContextMockTest) Del

func (s *TxContextMockTest) Del(name string, key []byte) error

Del del kv

func (*TxContextMockTest) Get

func (s *TxContextMockTest) Get(name string, key []byte) ([]byte, error)

Get get by key

func (*TxContextMockTest) GetAccessControl

func (s *TxContextMockTest) GetAccessControl() (protocol.AccessControlProvider, error)

GetAccessControl get access control

func (*TxContextMockTest) GetBlockFingerprint added in v2.3.0

func (s *TxContextMockTest) GetBlockFingerprint() string

GetBlockFingerprint returns unique id for block

func (*TxContextMockTest) GetBlockHeight

func (*TxContextMockTest) GetBlockHeight() uint64

GetBlockHeight get block height

func (*TxContextMockTest) GetBlockProposer

func (s *TxContextMockTest) GetBlockProposer() *acPb.Member

GetBlockProposer get block proposer

func (*TxContextMockTest) GetBlockTimestamp added in v2.2.0

func (s *TxContextMockTest) GetBlockTimestamp() int64

GetBlockTimestamp get block timestamp mock

func (*TxContextMockTest) GetBlockVersion

func (s *TxContextMockTest) GetBlockVersion() uint32

GetBlockVersion get block version

func (*TxContextMockTest) GetBlockchainStore

func (*TxContextMockTest) GetBlockchainStore() protocol.BlockchainStore

GetBlockchainStore get block chain store

func (*TxContextMockTest) GetChainNodesInfoProvider

func (s *TxContextMockTest) GetChainNodesInfoProvider() (protocol.ChainNodesInfoProvider, error)

GetChainNodesInfoProvider get chain nodes info provider

func (*TxContextMockTest) GetContractByName

func (s *TxContextMockTest) GetContractByName(name string) (*commonPb.Contract, error)

GetContractByName get contract by name

func (*TxContextMockTest) GetContractBytecode

func (s *TxContextMockTest) GetContractBytecode(name string) ([]byte, error)

GetContractBytecode get contract by code

func (*TxContextMockTest) GetCreator

func (s *TxContextMockTest) GetCreator(namespace string) *acPb.Member

GetCreator get creator

func (*TxContextMockTest) GetCrossInfo added in v2.3.0

func (s *TxContextMockTest) GetCrossInfo() uint64

GetCrossInfo get contract call link information

func (*TxContextMockTest) GetCurrentResult

func (s *TxContextMockTest) GetCurrentResult() []byte

GetCurrentResult Get current result

func (*TxContextMockTest) GetDepth

func (s *TxContextMockTest) GetDepth() int

GetDepth get depth

func (*TxContextMockTest) GetGasRemaining added in v2.3.3

func (s *TxContextMockTest) GetGasRemaining() uint64

GetGasRemaining add next time

@Description:
@receiver s
@return uint64

func (*TxContextMockTest) GetHistoryIterForKey added in v2.1.1

func (s *TxContextMockTest) GetHistoryIterForKey(contractName string, key []byte) (protocol.KeyHistoryIterator, error)

GetHistoryIterForKey get history iterator for key

func (*TxContextMockTest) GetIterHandle added in v2.1.1

func (s *TxContextMockTest) GetIterHandle(index int32) (interface{}, bool)

GetIterHandle get iterator handle

func (*TxContextMockTest) GetKeys added in v2.3.0

func (s *TxContextMockTest) GetKeys(keys []*vmPb.BatchKey) ([]*vmPb.BatchKey, error)

GetKeys key from cache, record this operation to read set

func (*TxContextMockTest) GetLastChainConfig added in v2.3.2

func (*TxContextMockTest) GetLastChainConfig() *configPb.ChainConfig

GetLastChainConfig returns last chain config

func (*TxContextMockTest) GetNoRecord added in v2.2.0

func (s *TxContextMockTest) GetNoRecord(contractName string, key []byte) ([]byte, error)

GetNoRecord get no record

func (*TxContextMockTest) GetSender

func (s *TxContextMockTest) GetSender() *acPb.Member

GetSender get sender

func (*TxContextMockTest) GetSnapshot added in v2.3.3

func (s *TxContextMockTest) GetSnapshot() protocol.Snapshot

GetSnapshot add next time

@Description:
@receiver s
@return protocol.Snapshot

func (*TxContextMockTest) GetStateKvHandle

func (s *TxContextMockTest) GetStateKvHandle(i int32) (protocol.StateIterator, bool)

GetStateKvHandle get state kv handle

func (*TxContextMockTest) GetStateSqlHandle

func (s *TxContextMockTest) GetStateSqlHandle(i int32) (protocol.SqlRows, bool)

GetStateSqlHandle get state sql handle

func (*TxContextMockTest) GetStrAddrFromPbMember added in v2.3.0

func (s *TxContextMockTest) GetStrAddrFromPbMember(pbMember *acPb.Member) (string, error)

GetStrAddrFromPbMember calculate string address from pb Member

func (*TxContextMockTest) GetTx

GetTx get tx

func (*TxContextMockTest) GetTxExecSeq

func (*TxContextMockTest) GetTxExecSeq() int

GetTxExecSeq get tx execute sequence

func (*TxContextMockTest) GetTxRWMapByContractName added in v2.3.0

func (s *TxContextMockTest) GetTxRWMapByContractName(contractName string) (map[string]*commonPb.TxRead,
	map[string]*commonPb.TxWrite)

GetTxRWMapByContractName get the read-write map of the specified contract of the current transaction

func (TxContextMockTest) GetTxRWSet

func (TxContextMockTest) GetTxRWSet(runVmSuccess bool) *commonPb.TxRWSet

GetTxRWSet get tx read write set

func (*TxContextMockTest) GetTxResult

func (s *TxContextMockTest) GetTxResult() *commonPb.Result

GetTxResult get tx result

func (*TxContextMockTest) HasUsed added in v2.3.0

func (s *TxContextMockTest) HasUsed(runtimeType commonPb.RuntimeType) bool

HasUsed judge whether the specified commonPb.RuntimeType has appeared in the previous depth in the current cross-link

func (*TxContextMockTest) Put

func (s *TxContextMockTest) Put(name string, key []byte, value []byte) error

Put put kv

func (*TxContextMockTest) PutIntoReadSet added in v2.1.1

func (s *TxContextMockTest) PutIntoReadSet(contractName string, key []byte, value []byte)

PutIntoReadSet put into read set

func (*TxContextMockTest) PutRecord

func (s *TxContextMockTest) PutRecord(contractName string, value []byte, sqlType protocol.SqlType)

PutRecord put record

func (*TxContextMockTest) RecordRuntimeTypeIntoCrossInfo added in v2.3.0

func (s *TxContextMockTest) RecordRuntimeTypeIntoCrossInfo(runtimeType commonPb.RuntimeType)

RecordRuntimeTypeIntoCrossInfo record the new contract call information to the top of crossInfo

func (*TxContextMockTest) RemoveRuntimeTypeFromCrossInfo added in v2.3.0

func (s *TxContextMockTest) RemoveRuntimeTypeFromCrossInfo()

RemoveRuntimeTypeFromCrossInfo remove the top-level information from the crossInfo

func (*TxContextMockTest) Select

func (s *TxContextMockTest) Select(name string, startKey []byte, limit []byte) (protocol.StateIterator, error)

Select select

func (*TxContextMockTest) SetIterHandle added in v2.1.1

func (s *TxContextMockTest) SetIterHandle(index int32, iter interface{})

SetIterHandle set iterator handle

func (*TxContextMockTest) SetStateKvHandle

func (s *TxContextMockTest) SetStateKvHandle(i int32, iterator protocol.StateIterator)

SetStateKvHandle set state kv handle

func (*TxContextMockTest) SetStateSqlHandle

func (s *TxContextMockTest) SetStateSqlHandle(i int32, rows protocol.SqlRows)

SetStateSqlHandle set state sql handle

func (*TxContextMockTest) SetTxExecSeq

func (*TxContextMockTest) SetTxExecSeq(i int)

SetTxExecSeq set tx execute sequence

func (*TxContextMockTest) SetTxResult

func (s *TxContextMockTest) SetTxResult(txResult *commonPb.Result)

SetTxResult set tx result

func (*TxContextMockTest) SubtractGas added in v2.3.3

func (s *TxContextMockTest) SubtractGas(gasUsed uint64) error

SubtractGas add next time

@Description:
@receiver s
@param gasUsed
@return error

Jump to

Keyboard shortcuts

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