test

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: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ContractNameTest is test contract name
	// ContractNameTest = "contract_test09"
	ContractNameTest = "contract_test106"
	// ContractNameAddr contract addr
	ContractNameAddr = "xxxxxxaddressfehis"

	// ContractVersionTest is test contract version
	ContractVersionTest = "v1.0.0"
)

Variables

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

CertFilePath is the test cert file path

View Source
var TxIds = []string{
	uuid.Generate().String(),
	uuid.Generate().String(),
	uuid.Generate().String(),
	uuid.Generate().String(),
	uuid.Generate().String(),
	uuid.Generate().String(),
	uuid.Generate().String(),
}

TxIds is a list of tx ids

Functions

func BaseParam

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

BaseParam is base params for test

func GetBlockVersion

func GetBlockVersion() uint32

GetBlockVersion get block version

Types

type GoLogger

type GoLogger struct{}

GoLogger is a golang system log implementation of protocol.Logger, it's for unit test

func (GoLogger) Debug

func (GoLogger) Debug(args ...interface{})

Debug is the debug log

func (GoLogger) DebugDynamic

func (GoLogger) DebugDynamic(l func() string)

DebugDynamic is the dynamic debug log

func (GoLogger) Debugf

func (GoLogger) Debugf(format string, args ...interface{})

Debugf is the debugf log

func (GoLogger) Debugw

func (GoLogger) Debugw(msg string, keysAndValues ...interface{})

Debugw is the debugw log

func (GoLogger) Error

func (GoLogger) Error(args ...interface{})

Error is the error log

func (GoLogger) Errorf

func (GoLogger) Errorf(format string, args ...interface{})

Errorf is the errorf log

func (GoLogger) Errorw

func (GoLogger) Errorw(msg string, keysAndValues ...interface{})

Errorw is the errorw log

func (GoLogger) Fatal

func (GoLogger) Fatal(args ...interface{})

Fatal is the fatal log

func (GoLogger) Fatalf

func (GoLogger) Fatalf(format string, args ...interface{})

Fatalf is the fatalf log

func (GoLogger) Fatalw

func (GoLogger) Fatalw(msg string, keysAndValues ...interface{})

Fatalw is the fatalw log

func (GoLogger) Info

func (GoLogger) Info(args ...interface{})

Info is the info log

func (GoLogger) InfoDynamic

func (GoLogger) InfoDynamic(l func() string)

InfoDynamic is the dynamic info log

func (GoLogger) Infof

func (GoLogger) Infof(format string, args ...interface{})

Infof is the infof log

func (GoLogger) Infow

func (GoLogger) Infow(msg string, keysAndValues ...interface{})

Infow is the infow log

func (GoLogger) Panic

func (GoLogger) Panic(args ...interface{})

Panic is the panic log

func (GoLogger) Panicf

func (GoLogger) Panicf(format string, args ...interface{})

Panicf is the panicf log

func (GoLogger) Panicw

func (GoLogger) Panicw(msg string, keysAndValues ...interface{})

Panicw is the panicw log

func (GoLogger) Warn

func (GoLogger) Warn(args ...interface{})

Warn is the warn log

func (GoLogger) Warnf

func (GoLogger) Warnf(format string, args ...interface{})

Warnf is the warnf log

func (GoLogger) Warnw

func (GoLogger) Warnw(msg string, keysAndValues ...interface{})

Warnw is the warn log

type TxContextMockTest

type TxContextMockTest struct {
	CacheMap map[string][]byte
	// contains filtered or unexported fields
}

TxContextMockTest mock tx context test

func InitContextTest

func InitContextTest() *TxContextMockTest

InitContextTest initialize TxContext and Contract

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 cross contract call, return (contract result, gas used)

func (*TxContextMockTest) Del

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

Del delete key from cache

func (*TxContextMockTest) Get

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

Get returns key from cache, record this operation to read set

func (*TxContextMockTest) GetAccessControl

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

GetAccessControl returns access control

func (*TxContextMockTest) GetBlockFingerprint

func (s *TxContextMockTest) GetBlockFingerprint() string

GetBlockFingerprint returns unique id for block

func (*TxContextMockTest) GetBlockHeight

func (*TxContextMockTest) GetBlockHeight() uint64

GetBlockHeight returns block height

func (*TxContextMockTest) GetBlockProposer

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

GetBlockProposer returns block proposer

func (*TxContextMockTest) GetBlockTimestamp

func (s *TxContextMockTest) GetBlockTimestamp() int64

GetBlockTimestamp returns block timestamp

func (*TxContextMockTest) GetBlockVersion

func (s *TxContextMockTest) GetBlockVersion() uint32

GetBlockVersion returns block version

func (*TxContextMockTest) GetBlockchainStore

func (*TxContextMockTest) GetBlockchainStore() protocol.BlockchainStore

GetBlockchainStore returns related blockchain store

func (*TxContextMockTest) GetChainNodesInfoProvider

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

GetChainNodesInfoProvider returns chain nodes info provider

func (*TxContextMockTest) GetConsensusStateWrapper

func (s *TxContextMockTest) GetConsensusStateWrapper() protocol.ConsensusStateWrapper

GetConsensusStateWrapper 获得共识状态 @return protocol.ConsensusStateWrapper

func (*TxContextMockTest) GetContractByName

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

GetContractByName returns contract name

func (*TxContextMockTest) GetContractBytecode

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

GetContractBytecode returns contract bytecode

func (*TxContextMockTest) GetCreator

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

GetCreator returns creator

func (*TxContextMockTest) GetCrossInfo

func (s *TxContextMockTest) GetCrossInfo() uint64

GetCrossInfo get contract call link information

func (*TxContextMockTest) GetCurrentResult

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

GetCurrentResult returns current result

func (*TxContextMockTest) GetDepth

func (s *TxContextMockTest) GetDepth() int

GetDepth returns cross contract call depth

func (*TxContextMockTest) GetGasRemaining added in v3.0.1

func (s *TxContextMockTest) GetGasRemaining() uint64

GetGasRemaining return gas remaining in txSimContext

func (*TxContextMockTest) GetHistoryIterForKey

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

GetHistoryIterForKey returns history iter for key

func (*TxContextMockTest) GetIterHandle

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

GetIterHandle returns iter

func (*TxContextMockTest) GetKeys

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

GetKeys GetKeys

func (*TxContextMockTest) GetLastChainConfig

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

GetLastChainConfig returns last chain config

func (*TxContextMockTest) GetNoRecord

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

GetNoRecord read data from state, but not record into read set, only used for framework

func (*TxContextMockTest) GetSender

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

GetSender returns sender

func (*TxContextMockTest) GetSnapshot

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

GetSnapshot 获得快照 @return protocol.Snapshot

func (*TxContextMockTest) GetStateKvHandle

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

GetStateKvHandle returns state kv handle

func (*TxContextMockTest) GetStateSqlHandle

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

GetStateSqlHandle returns get state sql

func (*TxContextMockTest) GetStrAddrFromPbMember

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

GetStrAddrFromPbMember calculate string address from pb Member

func (*TxContextMockTest) GetTx

GetTx returns tx

func (*TxContextMockTest) GetTxExecSeq

func (*TxContextMockTest) GetTxExecSeq() int

GetTxExecSeq returns tx exec seq

func (*TxContextMockTest) GetTxRWMapByContractName

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 returns tx rwset

func (*TxContextMockTest) GetTxResult

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

GetTxResult returns tx result

func (*TxContextMockTest) HasUsed

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

HasUsed judge whether the specified common.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 key into cache

func (*TxContextMockTest) PutIntoReadSet

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

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

RecordRuntimeTypeIntoCrossInfo add new vm runtime

func (*TxContextMockTest) RemoveRuntimeTypeFromCrossInfo

func (s *TxContextMockTest) RemoveRuntimeTypeFromCrossInfo()

RemoveRuntimeTypeFromCrossInfo remove runtime from cross info

func (*TxContextMockTest) Select

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

Select range query for key [start, limit)

func (*TxContextMockTest) SetIterHandle

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

SetIterHandle returns iter

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

func (*TxContextMockTest) SetTxExecSeq

func (*TxContextMockTest) SetTxExecSeq(i int)

SetTxExecSeq set tx exec seq

func (*TxContextMockTest) SetTxResult

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

SetTxResult set tx result

func (*TxContextMockTest) SubtractGas added in v3.0.1

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

SubtractGas subtract gas from txSimContext

Jump to

Keyboard shortcuts

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