testcommon

package
v1.5.29 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 36 Imported by: 3

Documentation

Overview

Package testcommon contains utility definitions used in unit and integration tests

Index

Constants

View Source
const (
	Sync = iota
	Async
	Callback
	AsyncCrossShard
	CallbackCrossShard
)

types of TestCallEdges

View Source
const AddressSize = 32

AddressSize is the size of an account address, in bytes.

View Source
const DefaultCallGraphLockedGas = 150

DefaultCallGraphLockedGas is the default gas locked value

View Source
const FakeCallbackName = "<>"

FakeCallbackName - used by test framework to reprezent visually a callback that is not present

View Source
const LeafLabel = "*"

LeafLabel - special node label for leafs

Variables

View Source
var CallbackData = []byte("callbackData")

CallbackData value exposed for test usage

View Source
var CallbackKey = []byte("callbackKey.....................")

CallbackKey value exposed for test usage

View Source
var ChildAddress = MakeTestSCAddressWithDefaultVM("childSC")

ChildAddress is an exposed value to use in tests

View Source
var ChildCompilationCostDestCtx uint64

ChildCompilationCostDestCtx value exposed for test usage

View Source
var ChildCompilationCostSameCtx uint64

ChildCompilationCostSameCtx value exposed for test usage

View Source
var ChildData = []byte("childData")

ChildData value exposed for test usage

View Source
var ChildFinish = []byte("childFinish")

ChildFinish value exposed for test usage

View Source
var ChildKey = []byte("childKey........................")

ChildKey value exposed for test usage

View Source
var ChildKeyB = []byte("childKeyB........................")

ChildKeyB value exposed for test usage

View Source
var ChildTransferReceiver = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0fchildTransferReceiver.")

ChildTransferReceiver value exposed for test usage

View Source
var DefaultCodeMetadata = []byte{3, 0}

DefaultCodeMetadata is an exposed value to use in tests

View Source
var DefaultVMType = []byte{0xF, 0xF}

DefaultVMType is an exposed value to use in tests

View Source
var ESDTTestTokenName = []byte("TTT-010101")

ESDTTestTokenName is an exposed value to use in tests

View Source
var ESDTTransferGasCost = uint64(1)

ESDTTransferGasCost is an exposed value to use in tests

View Source
var ErrAccountNotFound = errors.New("account not found")

ErrAccountNotFound is an exposed value to use in tests

View Source
var ErrAsyncCallFail = fmt.Errorf("async call fail")

ErrAsyncCallFail -

View Source
var ErrAsyncCallbackFail = fmt.Errorf("callback fail")

ErrAsyncCallbackFail -

View Source
var ErrAsyncRegisterFail = fmt.Errorf("unable to register async call")

ErrAsyncRegisterFail -

View Source
var ErrSyncCallFail = fmt.Errorf("sync call fail")

ErrSyncCallFail -

View Source
var GasProvided = uint64(1000000)

GasProvided value exposed for test usage

View Source
var LogGraph = logger.GetOrCreate("vm/graph")

LogGraph -

View Source
var NephewAddress = MakeTestSCAddressWithDefaultVM("NephewAddress")

NephewAddress is an exposed value to use in tests

View Source
var OriginalCallerCallback = []byte("originalCallerCallback")

OriginalCallerCallback value exposed for test usage

View Source
var OriginalCallerChild = []byte("originalCallerChild")

OriginalCallerChild value exposed for test usage

View Source
var OriginalCallerParent = []byte("originalCallerParent")

OriginalCallerParent value exposed for test usage

View Source
var ParentAddress = MakeTestSCAddressWithDefaultVM("parentSC")

ParentAddress is an exposed value to use in tests

View Source
var ParentCompilationCostDestCtx uint64

ParentCompilationCostDestCtx value exposed for test usage

View Source
var ParentCompilationCostSameCtx uint64

ParentCompilationCostSameCtx value exposed for test usage

View Source
var ParentDataA = []byte("parentDataA")

ParentDataA value exposed for test usage

View Source
var ParentDataB = []byte("parentDataB")

ParentDataB value exposed for test usage

View Source
var ParentFinishA = []byte("parentFinishA")

ParentFinishA value exposed for test usage

View Source
var ParentFinishB = []byte("parentFinishB")

ParentFinishB value exposed for test usage

View Source
var ParentKeyA = []byte("parentKeyA......................")

ParentKeyA value exposed for test usage

View Source
var ParentKeyB = []byte("parentKeyB......................")

ParentKeyB value exposed for test usage

View Source
var ParentTransferData = []byte("parentTransferData")

ParentTransferData value exposed for test usage

View Source
var ParentTransferReceiver = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0fparentTransferReceiver")

ParentTransferReceiver value exposed for test usage

View Source
var ParentTransferValue = int64(42)

ParentTransferValue value exposed for test usage

View Source
var RecursiveIterationBigCounterKey = []byte("recursiveIterationBigCounter....")

RecursiveIterationBigCounterKey value exposed for test usage

View Source
var RecursiveIterationCounterKey = []byte("recursiveIterationCounter.......")

RecursiveIterationCounterKey value exposed for test usage

View Source
var SCAddressPrefix = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0f")

SCAddressPrefix is the prefix of any smart contract address used for testing.

View Source
var TestCallbackPrefix = "callback_"

TestCallbackPrefix -

View Source
var TestContextCallbackFunction = "contextCallback"

TestContextCallbackFunction -

View Source
var TestReturnDataSuffix = "_returnData"

TestReturnDataSuffix -

View Source
var ThirdPartyAddress = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0fthirdPartyAddress.....")

ThirdPartyAddress value exposed for test usage

View Source
var UserAddress = MakeTestSCAddressWithDefaultVM("userAccount")

UserAddress is an exposed value to use in tests

View Source
var UserAddress2 = []byte("userAccount2....................")

UserAddress2 is an exposed value to use in tests

View Source
var VaultAddress = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0fvaultAddress..........")

VaultAddress value exposed for test usage

View Source
var WasmVirtualMachine = []byte{5, 0}

Functions

func AddFinishData

func AddFinishData(vmOutput *vmcommon.VMOutput, data []byte)

AddFinishData appends the provided []byte to the ReturnData of the given vmOutput

func AddNewOutputTransfer

func AddNewOutputTransfer(vmOutput *vmcommon.VMOutput, index uint32, sender []byte, address []byte, balanceDelta int64, data []byte) *vmcommon.OutputAccount

AddNewOutputTransfer creates a new vmcommon.OutputAccount from the provided arguments and adds it to OutputAccounts of the provided vmOutput

func AddTestSmartContractToWorld

func AddTestSmartContractToWorld(world *worldmock.MockWorld, identifier string, code []byte) *worldmock.Account

AddTestSmartContractToWorld directly deploys the provided code into the given MockWorld under a SC address built with the given identifier.

func BlockchainHookStubForCall

func BlockchainHookStubForCall(code []byte, balance *big.Int) *contextmock.BlockchainHookStub

BlockchainHookStubForCall creates a BlockchainHookStub

func BlockchainHookStubForCallSigSegv

func BlockchainHookStubForCallSigSegv(code []byte, balance *big.Int) *contextmock.BlockchainHookStub

BlockchainHookStubForCallSigSegv -

func BlockchainHookStubForContracts

func BlockchainHookStubForContracts(
	contracts []*InstanceTestSmartContract,
) *contextmock.BlockchainHookStub

BlockchainHookStubForContracts -

func BlockchainHookStubForTwoSCs

func BlockchainHookStubForTwoSCs(
	parentCode []byte,
	childCode []byte,
	parentSCBalance *big.Int,
	childSCBalance *big.Int,
) *contextmock.BlockchainHookStub

BlockchainHookStubForTwoSCs creates a world stub configured for testing calls between 2 SmartContracts

func CreateSvg

func CreateSvg(file string, graphviz *gographviz.Graph)

CreateSvg -

func CreateSvgWithLocation

func CreateSvgWithLocation(folder string, file string, graphviz *gographviz.Graph)

CreateSvgWithLocation -

func DefaultTestContractCallInput

func DefaultTestContractCallInput() *vmcommon.ContractCallInput

DefaultTestContractCallInput creates a vmcommon.ContractCallInput struct with default values.

func DefaultTestContractCreateInput

func DefaultTestContractCreateInput() *vmcommon.ContractCreateInput

DefaultTestContractCreateInput creates a vmcommon.ContractCreateInput struct with default values.

func GenerateSVGforGraph

func GenerateSVGforGraph(callGraph *TestCallGraph, folder string, name string)

GenerateSVGforGraph -

func GetSCCode

func GetSCCode(fileName string) []byte

GetSCCode retrieves the bytecode of a WASM module from a file

func GetTestSCCode

func GetTestSCCode(scName string, prefixToTestSCs ...string) []byte

GetTestSCCode retrieves the bytecode of a WASM testing contract

func GetTestSCCodeModule

func GetTestSCCodeModule(scName string, moduleName string, prefixToTestSCs string) []byte

GetTestSCCodeModule retrieves the bytecode of a WASM testing contract, given a specific name of the WASM module

func MakeEmptyVMOutput

func MakeEmptyVMOutput() *vmcommon.VMOutput

MakeEmptyVMOutput creates a vmcommon.VMOutput struct with default values

func MakeTestSCAddress

func MakeTestSCAddress(identifier string) []byte

MakeTestSCAddress generates a new smart contract address to be used for testing based on the given identifier.

func MakeTestSCAddressWithDefaultVM

func MakeTestSCAddressWithDefaultVM(identifier string) []byte

MakeTestSCAddressWithDefaultVM generates a new smart contract address to be used for testing based on the given identifier.

func MakeTestSCAddressWithVMType

func MakeTestSCAddressWithVMType(identifier string, vmType []byte) []byte

MakeTestSCAddressWithVMType generates a new smart contract address to be used for testing based on the given identifier.

func SimpleWasteGasMockMethod

func SimpleWasteGasMockMethod(instanceMock *mock.InstanceMock, gas uint64) func() *mock.InstanceMock

SimpleWasteGasMockMethod is a simple waste gas mock method

func ToGraphviz

func ToGraphviz(graph *TestCallGraph, showGasEdgeLabels bool) *gographviz.Graph

ToGraphviz -

func WasteGasWithReturnDataMockMethod

func WasteGasWithReturnDataMockMethod(instanceMock *mock.InstanceMock, gas uint64, returnData []byte) func() *mock.InstanceMock

WasteGasWithReturnDataMockMethod is a simple waste gas mock method

Types

type AssertResultsFunc

type AssertResultsFunc func(world *worldmock.MockWorld, verify *VMOutputVerifier)

AssertResultsFunc -

type AssertResultsWithStartNodeFunc

type AssertResultsWithStartNodeFunc func(startNode *TestCallNode, world *worldmock.MockWorld, verify *VMOutputVerifier, expectedErrorsForRound []string)

AssertResultsWithStartNodeFunc -

type CallFinishDataItem

type CallFinishDataItem struct {
	OriginalCallerAddr           []byte
	ContractAndFunction          string
	GasProvided                  uint64
	GasRemaining                 uint64
	CallID                       []byte
	CallbackAsyncInitiatorCallID []byte
	IsCrossShard                 bool
	FailError                    error
}

CallFinishDataItem -

type CallsFinishData

type CallsFinishData struct {
	Data []*CallFinishDataItem
}

CallsFinishData -

type ContractCallInputBuilder

type ContractCallInputBuilder struct {
	vmcommon.ContractCallInput
	CurrentESDTTransferIndex int
}

ContractCallInputBuilder extends a ContractCallInput for extra building functionality during testing

func CreateTestContractCallInputBuilder

func CreateTestContractCallInputBuilder() *ContractCallInputBuilder

CreateTestContractCallInputBuilder is a builder for ContractCallInputBuilder

func (*ContractCallInputBuilder) Build

func (contractInput *ContractCallInputBuilder) Build() *vmcommon.ContractCallInput

Build completes the build of a ContractCallInput

func (*ContractCallInputBuilder) NextESDTTransfer

func (contractInput *ContractCallInputBuilder) NextESDTTransfer() *ContractCallInputBuilder

func (*ContractCallInputBuilder) WithArguments

func (contractInput *ContractCallInputBuilder) WithArguments(arguments ...[]byte) *ContractCallInputBuilder

WithArguments provides the arguments to be called for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithAsyncArguments

func (contractInput *ContractCallInputBuilder) WithAsyncArguments(arguments *vmcommon.AsyncArguments) *ContractCallInputBuilder

WithAsyncArguments provides the async arguments to be called for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithCallType

func (contractInput *ContractCallInputBuilder) WithCallType(callType vm.CallType) *ContractCallInputBuilder

WithCallType provides the arguments to be called for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithCallValue

func (contractInput *ContractCallInputBuilder) WithCallValue(value int64) *ContractCallInputBuilder

WithCallValue provides the value transferred to the called contract

func (*ContractCallInputBuilder) WithCallerAddr

func (contractInput *ContractCallInputBuilder) WithCallerAddr(address []byte) *ContractCallInputBuilder

WithCallerAddr provides the caller address of ContractCallInputBuilder

func (*ContractCallInputBuilder) WithCurrentTxHash

func (contractInput *ContractCallInputBuilder) WithCurrentTxHash(txHash []byte) *ContractCallInputBuilder

WithCurrentTxHash provides the CurrentTxHash for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithESDTTokenName

func (contractInput *ContractCallInputBuilder) WithESDTTokenName(esdtTokenName []byte) *ContractCallInputBuilder

WithESDTTokenName provides the ESDTTokenName for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithESDTValue

func (contractInput *ContractCallInputBuilder) WithESDTValue(esdtValue *big.Int) *ContractCallInputBuilder

WithESDTValue provides the ESDTValue for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithFunction

func (contractInput *ContractCallInputBuilder) WithFunction(function string) *ContractCallInputBuilder

WithFunction provides the function to be called for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithGasLocked

func (contractInput *ContractCallInputBuilder) WithGasLocked(gas uint64) *ContractCallInputBuilder

WithGasLocked provides the locked gas of ContractCallInputBuilder

func (*ContractCallInputBuilder) WithGasProvided

func (contractInput *ContractCallInputBuilder) WithGasProvided(gas uint64) *ContractCallInputBuilder

WithGasProvided provides the gas of ContractCallInputBuilder

func (*ContractCallInputBuilder) WithPrevTxHash

func (contractInput *ContractCallInputBuilder) WithPrevTxHash(txHash []byte) *ContractCallInputBuilder

WithPrevTxHash provides the PrevTxHash for ContractCallInputBuilder

func (*ContractCallInputBuilder) WithRecipientAddr

func (contractInput *ContractCallInputBuilder) WithRecipientAddr(address []byte) *ContractCallInputBuilder

WithRecipientAddr provides the recepient address of ContractCallInputBuilder

type ContractCreateInputBuilder

type ContractCreateInputBuilder struct {
	vmcommon.ContractCreateInput
}

ContractCreateInputBuilder extends a ContractCreateInput for extra building functionality during testing

func CreateTestContractCreateInputBuilder

func CreateTestContractCreateInputBuilder() *ContractCreateInputBuilder

CreateTestContractCreateInputBuilder is a builder for ContractCreateInputBuilder

func (*ContractCreateInputBuilder) Build

Build completes the build of a ContractCreateInput

func (*ContractCreateInputBuilder) WithArguments

func (contractInput *ContractCreateInputBuilder) WithArguments(arguments ...[]byte) *ContractCreateInputBuilder

WithArguments provides the Arguments for a ContractCreateInputBuilder

func (*ContractCreateInputBuilder) WithCallValue

func (contractInput *ContractCreateInputBuilder) WithCallValue(callValue int64) *ContractCreateInputBuilder

WithCallValue provides the CallValue for a ContractCreateInputBuilder

func (*ContractCreateInputBuilder) WithCallerAddr

func (contractInput *ContractCreateInputBuilder) WithCallerAddr(address []byte) *ContractCreateInputBuilder

WithCallerAddr provides the CallerAddr for a ContractCreateInputBuilder

func (*ContractCreateInputBuilder) WithContractCode

func (contractInput *ContractCreateInputBuilder) WithContractCode(code []byte) *ContractCreateInputBuilder

WithContractCode provides the ContractCode for a ContractCreateInputBuilder

func (*ContractCreateInputBuilder) WithContractCodeMetadata added in v1.5.25

func (contractInput *ContractCreateInputBuilder) WithContractCodeMetadata(codemetadata []byte) *ContractCreateInputBuilder

WithContractCodeMetadata provides the ContractCodeMetadata for a ContractCreateInputBuilder

func (*ContractCreateInputBuilder) WithGasProvided

func (contractInput *ContractCreateInputBuilder) WithGasProvided(gas uint64) *ContractCreateInputBuilder

WithGasProvided provides the GasProvided for a ContractCreateInputBuilder

type CrossShardCall

type CrossShardCall struct {
	CallerAddress []byte
	StartNode     *TestCallNode
	CallType      vm.CallType
	AsyncData     []byte
	Data          []byte
	ParentsPath   []*TestCallNode
}

CrossShardCall -

type CrossShardCallsQueue

type CrossShardCallsQueue struct {
	Data []*CrossShardCall
}

CrossShardCallsQueue -

func NewCrossShardCallQueue

func NewCrossShardCallQueue() *CrossShardCallsQueue

NewCrossShardCallQueue -

func (*CrossShardCallsQueue) CanExecuteLocalCallback

func (queue *CrossShardCallsQueue) CanExecuteLocalCallback(callbackNode *TestCallNode) bool

CanExecuteLocalCallback - in case of async local calls, search queue for pending children of the start of this edge

func (*CrossShardCallsQueue) Dequeue

func (queue *CrossShardCallsQueue) Dequeue() *CrossShardCall

Dequeue -

func (*CrossShardCallsQueue) Enqueue

func (queue *CrossShardCallsQueue) Enqueue(callerAddress []byte, startNode *TestCallNode, callType vm.CallType,
	asyncData []byte, data []byte)

Enqueue -

func (*CrossShardCallsQueue) IsEmpty

func (queue *CrossShardCallsQueue) IsEmpty() bool

IsEmpty -

func (*CrossShardCallsQueue) Len

func (queue *CrossShardCallsQueue) Len() int

Len -

func (*CrossShardCallsQueue) Less

func (queue *CrossShardCallsQueue) Less(i, j int) bool

Less -

func (*CrossShardCallsQueue) Requeue

func (queue *CrossShardCallsQueue) Requeue(crossShardCall *CrossShardCall)

Requeue -

func (*CrossShardCallsQueue) Swap

func (queue *CrossShardCallsQueue) Swap(i, j int)

Swap -

func (*CrossShardCallsQueue) Top

func (queue *CrossShardCallsQueue) Top() *CrossShardCall

Top -

type InstanceCallTestTemplate

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

InstanceCallTestTemplate holds the data to build a contract call test

func BuildInstanceCallTest

func BuildInstanceCallTest(tb testing.TB) *InstanceCallTestTemplate

BuildInstanceCallTest starts the building process for a contract call test

func (*InstanceCallTestTemplate) AndAssertResults

func (template *InstanceCallTestTemplate) AndAssertResults(assertResults func(vmhost.VMHost, *contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResults starts the test and asserts the results

func (*InstanceCallTestTemplate) AndAssertResultsWithoutReset

func (template *InstanceCallTestTemplate) AndAssertResultsWithoutReset(assertResults func(vmhost.VMHost, *contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResultsWithoutReset starts the test and asserts the results

func (*InstanceCallTestTemplate) GetVMHost

func (template *InstanceCallTestTemplate) GetVMHost() vmhost.VMHost

GetVMHost returns the inner VMHost

func (*InstanceCallTestTemplate) WithContracts

func (template *InstanceCallTestTemplate) WithContracts(usedContracts ...*InstanceTestSmartContract) *InstanceCallTestTemplate

WithContracts provides the contracts to be used by the contract call test

func (*InstanceCallTestTemplate) WithExecutorFactory

func (template *InstanceCallTestTemplate) WithExecutorFactory(executorFactory executor.ExecutorAbstractFactory) *InstanceCallTestTemplate

WithExecutorFactory provides the wasmer executor for the test

func (*InstanceCallTestTemplate) WithExecutorLogs

func (template *InstanceCallTestTemplate) WithExecutorLogs(executorLogger executorwrapper.ExecutorLogger) *InstanceCallTestTemplate

WithExecutorLogs sets an ExecutorLogger

func (*InstanceCallTestTemplate) WithGasSchedule

func (template *InstanceCallTestTemplate) WithGasSchedule(gasSchedule config.GasScheduleMap) *InstanceCallTestTemplate

WithGasSchedule provides gas schedule for the test

func (*InstanceCallTestTemplate) WithInput

WithInput provides the ContractCallInput to be used by the contract call test

func (*InstanceCallTestTemplate) WithSetup

WithSetup provides the setup function to be used by the contract call test

func (*InstanceCallTestTemplate) WithWasmerSIGSEGVPassthrough

func (template *InstanceCallTestTemplate) WithWasmerSIGSEGVPassthrough(passthrough bool) *InstanceCallTestTemplate

WithWasmerSIGSEGVPassthrough sets the wasmerSIGSEGVPassthrough flag

type InstanceCreatorTestTemplate

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

InstanceCreatorTestTemplate holds the data to build a contract creation test

func BuildInstanceCreatorTest

func BuildInstanceCreatorTest(tb testing.TB) *InstanceCreatorTestTemplate

BuildInstanceCreatorTest starts the building process for a contract creation test

func (*InstanceCreatorTestTemplate) AndAssertResults

func (template *InstanceCreatorTestTemplate) AndAssertResults(assertResults func(*contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResults provides the function that will aserts the results

func (*InstanceCreatorTestTemplate) AndAssertResultsWithoutReset

func (template *InstanceCreatorTestTemplate) AndAssertResultsWithoutReset(assertResults func(*contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResultsWithoutReset provides the function that will aserts the results

func (*InstanceCreatorTestTemplate) RunTest added in v1.5.8

RunTest executes the built test directly, without any assertions.

func (*InstanceCreatorTestTemplate) WithAddress

func (template *InstanceCreatorTestTemplate) WithAddress(address []byte) *InstanceCreatorTestTemplate

WithAddress provides the address for a TestCreateTemplateConfig

func (*InstanceCreatorTestTemplate) WithExecutorFactory

WithExecutorFactory allows caller to choose the Executor type.

func (*InstanceCreatorTestTemplate) WithExecutorLogs

func (template *InstanceCreatorTestTemplate) WithExecutorLogs(executorLogger executorwrapper.ExecutorLogger) *InstanceCreatorTestTemplate

WithExecutorLogs sets an ExecutorLogger

func (*InstanceCreatorTestTemplate) WithInput

WithInput provides the ContractCreateInput for a TestCreateTemplateConfig

func (*InstanceCreatorTestTemplate) WithSetup

WithSetup provides the setup function for a TestCreateTemplateConfig

func (*InstanceCreatorTestTemplate) WithWasmerSIGSEGVPassthrough

func (template *InstanceCreatorTestTemplate) WithWasmerSIGSEGVPassthrough(passthrough bool) *InstanceCreatorTestTemplate

WithWasmerSIGSEGVPassthrough sets the wasmerSIGSEGVPassthrough flag

type InstanceTestSmartContract

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

InstanceTestSmartContract represents the config data for the smart contract instance to be tested

func CreateInstanceContract

func CreateInstanceContract(address []byte) *InstanceTestSmartContract

CreateInstanceContract build a contract to be used in a test creted with BuildInstanceCallTest

func (*InstanceTestSmartContract) WithBalance

func (mockSC *InstanceTestSmartContract) WithBalance(balance int64) *InstanceTestSmartContract

WithBalance provides the balance for the InstanceTestSmartContract

func (*InstanceTestSmartContract) WithCode

func (mockSC *InstanceTestSmartContract) WithCode(code []byte) *InstanceTestSmartContract

WithCode provides the code for the InstanceTestSmartContract

func (*InstanceTestSmartContract) WithCodeMetadata

func (mockSC *InstanceTestSmartContract) WithCodeMetadata(metadata []byte) *InstanceTestSmartContract

WithCodeMetadata provides the owner for the InstanceTestSmartContract

func (*InstanceTestSmartContract) WithConfig

func (mockSC *InstanceTestSmartContract) WithConfig(testConfig *TestConfig) *InstanceTestSmartContract

WithConfig provides the config object for the InstanceTestSmartContract

func (*InstanceTestSmartContract) WithOwner

func (mockSC *InstanceTestSmartContract) WithOwner(owner []byte) *InstanceTestSmartContract

WithOwner provides the owner for the InstanceTestSmartContract

type MockBuiltin

type MockBuiltin struct {
	ProcessBuiltinFunctionCall func(acntSnd, _ vmcommon.UserAccountHandler, vmInput *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)
	// contains filtered or unexported fields
}

MockBuiltin defined the functions that can be replaced in order to mock a builtin

func (*MockBuiltin) IsActive

func (m *MockBuiltin) IsActive() bool

IsActive -

func (*MockBuiltin) IsInterfaceNil

func (m *MockBuiltin) IsInterfaceNil() bool

IsInterfaceNil - see BuiltinFunction.IsInterfaceNil()

func (*MockBuiltin) ProcessBuiltinFunction

func (m *MockBuiltin) ProcessBuiltinFunction(acntSnd, acntRcv vmcommon.UserAccountHandler, vmInput *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)

ProcessBuiltinFunction - see BuiltinFunction.ProcessBuiltInFunction()

func (*MockBuiltin) SetNewGasConfig

func (m *MockBuiltin) SetNewGasConfig(gasCost *vmcommon.GasCost)

SetNewGasConfig - see BuiltinFunction.SetNewGasConfig()

type MockInstancesTestTemplate

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

MockInstancesTestTemplate holds the data to build a mock contract call test

func BuildMockInstanceCallTest

func BuildMockInstanceCallTest(tb testing.TB) *MockInstancesTestTemplate

BuildMockInstanceCallTest starts the building process for a mock contract call test

func (*MockInstancesTestTemplate) AndAssertResults

func (callerTest *MockInstancesTestTemplate) AndAssertResults(assertResults AssertResultsFunc) (*vmcommon.VMOutput, error)

AndAssertResults provides the function that will aserts the results

func (*MockInstancesTestTemplate) AndAssertResultsWithWorld

func (callerTest *MockInstancesTestTemplate) AndAssertResultsWithWorld(
	world *worldmock.MockWorld,
	createAccount bool,
	startNode *TestCallNode,
	expectedErrorsForRound []string,
	assertResults AssertResultsWithStartNodeFunc) (*vmcommon.VMOutput, error)

AndAssertResultsWithWorld provides the function that will aserts the results

func (*MockInstancesTestTemplate) AndCreateAndAssertResults

func (callerTest *MockInstancesTestTemplate) AndCreateAndAssertResults(assertResults AssertResultsFunc) (*vmcommon.VMOutput, error)

AndCreateAndAssertResults provides the function that will create the contract and aserts the results

func (*MockInstancesTestTemplate) RunTest added in v1.5.8

func (callerTest *MockInstancesTestTemplate) RunTest(
	world *worldmock.MockWorld,
	createContractAccounts bool,
	testType TestType,
) (vmhost.VMHost, *vmcommon.VMOutput, error)

RunTest executes the built test directly, without any assertions.

func (*MockInstancesTestTemplate) WithContracts

func (callerTest *MockInstancesTestTemplate) WithContracts(usedContracts ...MockTestSmartContract) *MockInstancesTestTemplate

WithContracts provides the contracts to be used by the mock contract call test

func (*MockInstancesTestTemplate) WithInput

WithInput provides the ContractCallInput to be used by the mock contract call test

func (*MockInstancesTestTemplate) WithSetup

WithSetup provides the setup function to be used by the mock contract call test

func (*MockInstancesTestTemplate) WithWasmerSIGSEGVPassthrough

func (callerTest *MockInstancesTestTemplate) WithWasmerSIGSEGVPassthrough(wasmerSIGSEGVPassthrough bool) *MockInstancesTestTemplate

WithWasmerSIGSEGVPassthrough sets the wasmerSIGSEGVPassthrough flag

type MockTestSmartContract

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

MockTestSmartContract represents the config data for the mock smart contract instance to be tested

func CreateMockContract

func CreateMockContract(address []byte) *MockTestSmartContract

CreateMockContract build a contract to be used in a test creted with BuildMockInstanceCallTest

func CreateMockContractOnShard

func CreateMockContractOnShard(address []byte, shardID uint32) *MockTestSmartContract

CreateMockContractOnShard build a contract to be used in a test creted with BuildMockInstanceCallTest

func CreateMockContractsFromAsyncTestCallGraph

func CreateMockContractsFromAsyncTestCallGraph(callGraph *TestCallGraph, callsFinishData *CallsFinishData, runtimeConfigsForCalls map[string]*RuntimeConfigOfCall, testConfig *TestConfig) []MockTestSmartContract

CreateMockContractsFromAsyncTestCallGraph creates the contracts with functions that reflect the behavior specified by the call graph

func (*MockTestSmartContract) GetShardID

func (mockSC *MockTestSmartContract) GetShardID() uint32

GetShardID -

func (*MockTestSmartContract) GetVMType

func (mockSC *MockTestSmartContract) GetVMType() []byte

GetVMType -

func (*MockTestSmartContract) Initialize

func (mockSC *MockTestSmartContract) Initialize(
	t testing.TB,
	host vmhost.VMHost,
	imb *mock.ExecutorMock,
	createContractAccounts bool,
)

Initialize -

func (*MockTestSmartContract) WithBalance

func (mockSC *MockTestSmartContract) WithBalance(balance int64) *MockTestSmartContract

WithBalance provides the balance for the MockTestSmartContract

func (*MockTestSmartContract) WithCodeHash

func (mockSC *MockTestSmartContract) WithCodeHash(codeHash []byte) *MockTestSmartContract

WithCodeHash provides the code hash for the MockTestSmartContract

func (*MockTestSmartContract) WithCodeMetadata

func (mockSC *MockTestSmartContract) WithCodeMetadata(codeMetadata []byte) *MockTestSmartContract

WithCodeMetadata provides the code metadata for the MockTestSmartContract

func (*MockTestSmartContract) WithConfig

func (mockSC *MockTestSmartContract) WithConfig(config *TestConfig) *MockTestSmartContract

WithConfig provides the config object for the MockTestSmartContract

func (*MockTestSmartContract) WithMethods

func (mockSC *MockTestSmartContract) WithMethods(initMethods ...func(*mock.InstanceMock, interface{})) MockTestSmartContract

WithMethods provides the methods for the MockTestSmartContract

func (*MockTestSmartContract) WithOwnerAddress

func (mockSC *MockTestSmartContract) WithOwnerAddress(ownerAddress []byte) *MockTestSmartContract

WithOwnerAddress provides the owner address for the MockTestSmartContract

func (*MockTestSmartContract) WithShardID

func (mockSC *MockTestSmartContract) WithShardID(shardID uint32) *MockTestSmartContract

WithShardID provides the shardID for the MockTestSmartContract

func (*MockTestSmartContract) WithVMType

func (mockSC *MockTestSmartContract) WithVMType(vmType []byte) *MockTestSmartContract

WithBalance provides the balance for the MockTestSmartContract

type RuntimeConfigOfCall

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

RuntimeConfigOfCall -

type SetupFunction

type SetupFunction func(vmhost.VMHost, *worldmock.MockWorld)

SetupFunction -

type StoreEntry

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

StoreEntry holds the data for a storage assertion

func CreateStoreEntry

func CreateStoreEntry(address []byte) *StoreEntry

CreateStoreEntry creates the data for a storage assertion

func (*StoreEntry) IgnoreValue

func (storeEntry *StoreEntry) IgnoreValue() StoreEntry

IgnoreValue ignores the value for a storage assertion

func (*StoreEntry) WithKey

func (storeEntry *StoreEntry) WithKey(key []byte) *StoreEntry

WithKey sets the key for a storage assertion

func (*StoreEntry) WithValue

func (storeEntry *StoreEntry) WithValue(value []byte) StoreEntry

WithValue sets the value for a storage assertion

type TestCall

type TestCall struct {
	ContractAddress    []byte
	FunctionName       string
	CallID             []byte
	OriginalContractID string
}

TestCall represents the payload of a node in the call graph

func (*TestCall) ToString

func (call *TestCall) ToString() string

ToString - string representatin of a TestCall

type TestCallEdge

type TestCallEdge struct {
	ID uint

	Type TestCallEdgeType

	// callback function name
	Callback string

	// outgoing node
	To *TestCallNode

	// gas config for the outgoing node (represented by To)
	GasLimit          uint64
	GasUsed           uint64
	GasUsedByCallback uint64
	GasLocked         uint64

	// used only for visualization & debugging
	Label string

	Fail         bool
	ErrFail      error
	CallbackFail bool
}

TestCallEdge an edge between two nodes of the call graph

func (*TestCallEdge) IsFailFail

func (edge *TestCallEdge) IsFailFail() bool

IsFailFail -

func (*TestCallEdge) SetCallbackFail

func (edge *TestCallEdge) SetCallbackFail() *TestCallEdge

SetCallbackFail - builder style setter

func (*TestCallEdge) SetFail

func (edge *TestCallEdge) SetFail() *TestCallEdge

SetFail - builder style setter

func (*TestCallEdge) SetFailWithExpectedError

func (edge *TestCallEdge) SetFailWithExpectedError(expectedError error) *TestCallEdge

SetFailWithExpectedError - builder style setter

func (*TestCallEdge) SetGasLimit

func (edge *TestCallEdge) SetGasLimit(gasLimit uint64) *TestCallEdge

SetGasLimit - builder style setter

func (*TestCallEdge) SetGasLocked

func (edge *TestCallEdge) SetGasLocked(gasLocked uint64) *TestCallEdge

SetGasLocked - builder style setter

func (*TestCallEdge) SetGasUsed

func (edge *TestCallEdge) SetGasUsed(gasUsed uint64) *TestCallEdge

SetGasUsed - builder style setter

func (*TestCallEdge) SetGasUsedByCallback

func (edge *TestCallEdge) SetGasUsedByCallback(gasUsedByCallback uint64) *TestCallEdge

SetGasUsedByCallback - builder style setter

type TestCallEdgeType

type TestCallEdgeType int

TestCallEdgeType the type of TestCallEdges

type TestCallGraph

type TestCallGraph struct {
	Nodes     []*TestCallNode
	StartNode *TestCallNode

	Crypto crypto.VMCrypto
	// contains filtered or unexported fields
}

TestCallGraph is the call graph

func CreateGraphTestAsyncCallIndirectFail

func CreateGraphTestAsyncCallIndirectFail() *TestCallGraph

CreateGraphTestAsyncCallIndirectFail -

func CreateGraphTestAsyncCallIndirectFailCrossShard

func CreateGraphTestAsyncCallIndirectFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallIndirectFailCrossShard -

func CreateGraphTestAsyncCallbackIndirectFail

func CreateGraphTestAsyncCallbackIndirectFail() *TestCallGraph

CreateGraphTestAsyncCallbackIndirectFail -

func CreateGraphTestAsyncCallbackIndirectFailCrossShard

func CreateGraphTestAsyncCallbackIndirectFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallbackIndirectFailCrossShard -

func CreateGraphTestAsyncCallsAsync

func CreateGraphTestAsyncCallsAsync() *TestCallGraph

CreateGraphTestAsyncCallsAsync -

func CreateGraphTestAsyncCallsAsyncBothCallbacksFail

func CreateGraphTestAsyncCallsAsyncBothCallbacksFail() *TestCallGraph

CreateGraphTestAsyncCallsAsyncBothCallbacksFail -

func CreateGraphTestAsyncCallsAsyncBothCallbacksFailCrossLocal

func CreateGraphTestAsyncCallsAsyncBothCallbacksFailCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncBothCallbacksFailCrossLocal -

func CreateGraphTestAsyncCallsAsyncBothCallbacksFailCrossShard

func CreateGraphTestAsyncCallsAsyncBothCallbacksFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncBothCallbacksFailCrossShard -

func CreateGraphTestAsyncCallsAsyncBothCallbacksFailLocalCross

func CreateGraphTestAsyncCallsAsyncBothCallbacksFailLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncBothCallbacksFailLocalCross -

func CreateGraphTestAsyncCallsAsyncCrossLocal

func CreateGraphTestAsyncCallsAsyncCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncCrossLocal -

func CreateGraphTestAsyncCallsAsyncCrossShard

func CreateGraphTestAsyncCallsAsyncCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncCrossShard -

func CreateGraphTestAsyncCallsAsyncFirstCallbackFail

func CreateGraphTestAsyncCallsAsyncFirstCallbackFail() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstCallbackFail -

func CreateGraphTestAsyncCallsAsyncFirstCallbackFailCrossLocal

func CreateGraphTestAsyncCallsAsyncFirstCallbackFailCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstCallbackFailCrossLocal -

func CreateGraphTestAsyncCallsAsyncFirstCallbackFailCrossShard

func CreateGraphTestAsyncCallsAsyncFirstCallbackFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstCallbackFailCrossShard -

func CreateGraphTestAsyncCallsAsyncFirstCallbackFailLocalCross

func CreateGraphTestAsyncCallsAsyncFirstCallbackFailLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstCallbackFailLocalCross -

func CreateGraphTestAsyncCallsAsyncFirstFail

func CreateGraphTestAsyncCallsAsyncFirstFail() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstFail -

func CreateGraphTestAsyncCallsAsyncFirstFailCrossLocal

func CreateGraphTestAsyncCallsAsyncFirstFailCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstFailCrossLocal -

func CreateGraphTestAsyncCallsAsyncFirstFailCrossShard

func CreateGraphTestAsyncCallsAsyncFirstFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstFailCrossShard -

func CreateGraphTestAsyncCallsAsyncFirstFailLocalCross

func CreateGraphTestAsyncCallsAsyncFirstFailLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstFailLocalCross -

func CreateGraphTestAsyncCallsAsyncFirstNoCallback

func CreateGraphTestAsyncCallsAsyncFirstNoCallback() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstNoCallback -

func CreateGraphTestAsyncCallsAsyncFirstNoCallbackCrossLocal

func CreateGraphTestAsyncCallsAsyncFirstNoCallbackCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstNoCallbackCrossLocal -

func CreateGraphTestAsyncCallsAsyncFirstNoCallbackCrossShard

func CreateGraphTestAsyncCallsAsyncFirstNoCallbackCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstNoCallbackCrossShard -

func CreateGraphTestAsyncCallsAsyncFirstNoCallbackLocalCross

func CreateGraphTestAsyncCallsAsyncFirstNoCallbackLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncFirstNoCallbackLocalCross -

func CreateGraphTestAsyncCallsAsyncLocalCross

func CreateGraphTestAsyncCallsAsyncLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncLocalCross -

func CreateGraphTestAsyncCallsAsyncSecondCallbackFail

func CreateGraphTestAsyncCallsAsyncSecondCallbackFail() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondCallbackFail -

func CreateGraphTestAsyncCallsAsyncSecondCallbackFailCrossLocal

func CreateGraphTestAsyncCallsAsyncSecondCallbackFailCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondCallbackFailCrossLocal -

func CreateGraphTestAsyncCallsAsyncSecondCallbackFailCrossShard

func CreateGraphTestAsyncCallsAsyncSecondCallbackFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondCallbackFailCrossShard -

func CreateGraphTestAsyncCallsAsyncSecondCallbackFailLocalCross

func CreateGraphTestAsyncCallsAsyncSecondCallbackFailLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondCallbackFailLocalCross -

func CreateGraphTestAsyncCallsAsyncSecondFail

func CreateGraphTestAsyncCallsAsyncSecondFail() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondFail -

func CreateGraphTestAsyncCallsAsyncSecondFailCrossLocal

func CreateGraphTestAsyncCallsAsyncSecondFailCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondFailCrossLocal -

func CreateGraphTestAsyncCallsAsyncSecondFailCrossShard

func CreateGraphTestAsyncCallsAsyncSecondFailCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondFailCrossShard -

func CreateGraphTestAsyncCallsAsyncSecondFailLocalCross

func CreateGraphTestAsyncCallsAsyncSecondFailLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondFailLocalCross -

func CreateGraphTestAsyncCallsAsyncSecondNoCallback

func CreateGraphTestAsyncCallsAsyncSecondNoCallback() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondNoCallback -

func CreateGraphTestAsyncCallsAsyncSecondNoCallbackCrossLocal

func CreateGraphTestAsyncCallsAsyncSecondNoCallbackCrossLocal() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondNoCallbackCrossLocal -

func CreateGraphTestAsyncCallsAsyncSecondNoCallbackCrossShard

func CreateGraphTestAsyncCallsAsyncSecondNoCallbackCrossShard() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondNoCallbackCrossShard -

func CreateGraphTestAsyncCallsAsyncSecondNoCallbackLocalCross

func CreateGraphTestAsyncCallsAsyncSecondNoCallbackLocalCross() *TestCallGraph

CreateGraphTestAsyncCallsAsyncSecondNoCallbackLocalCross -

func CreateGraphTestAsyncCallsCrossShard2

func CreateGraphTestAsyncCallsCrossShard2() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard2 -

func CreateGraphTestAsyncCallsCrossShard3

func CreateGraphTestAsyncCallsCrossShard3() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard3 -

func CreateGraphTestAsyncCallsCrossShard4

func CreateGraphTestAsyncCallsCrossShard4() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard4 -

func CreateGraphTestAsyncCallsCrossShard5

func CreateGraphTestAsyncCallsCrossShard5() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard5 -

func CreateGraphTestAsyncCallsCrossShard6

func CreateGraphTestAsyncCallsCrossShard6() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard6 -

func CreateGraphTestAsyncCallsCrossShard7

func CreateGraphTestAsyncCallsCrossShard7() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard7 -

func CreateGraphTestAsyncCallsCrossShard8

func CreateGraphTestAsyncCallsCrossShard8() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard8 -

func CreateGraphTestAsyncCallsCrossShard9

func CreateGraphTestAsyncCallsCrossShard9() *TestCallGraph

CreateGraphTestAsyncCallsCrossShard9 -

func CreateGraphTestCallbackCallsAsyncCallbackFailCrossCross

func CreateGraphTestCallbackCallsAsyncCallbackFailCrossCross() *TestCallGraph

CreateGraphTestCallbackCallsAsyncCallbackFailCrossCross -

func CreateGraphTestCallbackCallsAsyncCallbackFailCrossLocal

func CreateGraphTestCallbackCallsAsyncCallbackFailCrossLocal() *TestCallGraph

CreateGraphTestCallbackCallsAsyncCallbackFailCrossLocal -

func CreateGraphTestCallbackCallsAsyncCallbackFailLocalCross

func CreateGraphTestCallbackCallsAsyncCallbackFailLocalCross() *TestCallGraph

CreateGraphTestCallbackCallsAsyncCallbackFailLocalCross -

func CreateGraphTestCallbackCallsAsyncCallbackFailLocalLocal

func CreateGraphTestCallbackCallsAsyncCallbackFailLocalLocal() *TestCallGraph

CreateGraphTestCallbackCallsAsyncCallbackFailLocalLocal -

func CreateGraphTestCallbackCallsAsyncCrossCross

func CreateGraphTestCallbackCallsAsyncCrossCross() *TestCallGraph

CreateGraphTestCallbackCallsAsyncCrossCross -

func CreateGraphTestCallbackCallsAsyncCrossLocal

func CreateGraphTestCallbackCallsAsyncCrossLocal() *TestCallGraph

CreateGraphTestCallbackCallsAsyncCrossLocal -

func CreateGraphTestCallbackCallsAsyncFailCrossCross

func CreateGraphTestCallbackCallsAsyncFailCrossCross() *TestCallGraph

CreateGraphTestCallbackCallsAsyncFailCrossCross -

func CreateGraphTestCallbackCallsAsyncFailCrossLocal

func CreateGraphTestCallbackCallsAsyncFailCrossLocal() *TestCallGraph

CreateGraphTestCallbackCallsAsyncFailCrossLocal -

func CreateGraphTestCallbackCallsAsyncFailLocalCross

func CreateGraphTestCallbackCallsAsyncFailLocalCross() *TestCallGraph

CreateGraphTestCallbackCallsAsyncFailLocalCross -

func CreateGraphTestCallbackCallsAsyncFailLocalLocal

func CreateGraphTestCallbackCallsAsyncFailLocalLocal() *TestCallGraph

CreateGraphTestCallbackCallsAsyncFailLocalLocal -

func CreateGraphTestCallbackCallsAsyncLocalCross

func CreateGraphTestCallbackCallsAsyncLocalCross() *TestCallGraph

CreateGraphTestCallbackCallsAsyncLocalCross -

func CreateGraphTestCallbackCallsAsyncLocalLocal

func CreateGraphTestCallbackCallsAsyncLocalLocal() *TestCallGraph

CreateGraphTestCallbackCallsAsyncLocalLocal -

func CreateGraphTestCallbackCallsSync

func CreateGraphTestCallbackCallsSync() *TestCallGraph

CreateGraphTestCallbackCallsSync -

func CreateGraphTestDifferentTypeOfCallsToSameFunction

func CreateGraphTestDifferentTypeOfCallsToSameFunction() *TestCallGraph

CreateGraphTestDifferentTypeOfCallsToSameFunction -

func CreateGraphTestOneAsyncCall

func CreateGraphTestOneAsyncCall() *TestCallGraph

CreateGraphTestOneAsyncCall -

func CreateGraphTestOneAsyncCallCrossShard

func CreateGraphTestOneAsyncCallCrossShard() *TestCallGraph

CreateGraphTestOneAsyncCallCrossShard -

func CreateGraphTestOneAsyncCallCrossShard2

func CreateGraphTestOneAsyncCallCrossShard2() *TestCallGraph

CreateGraphTestOneAsyncCallCrossShard2 -

func CreateGraphTestOneAsyncCallCustomGasLocked

func CreateGraphTestOneAsyncCallCustomGasLocked() *TestCallGraph

CreateGraphTestOneAsyncCallCustomGasLocked -

func CreateGraphTestOneAsyncCallFail

func CreateGraphTestOneAsyncCallFail() *TestCallGraph

CreateGraphTestOneAsyncCallFail -

func CreateGraphTestOneAsyncCallFailCrossShard

func CreateGraphTestOneAsyncCallFailCrossShard() *TestCallGraph

CreateGraphTestOneAsyncCallFailCrossShard -

func CreateGraphTestOneAsyncCallFailNoCallbackCrossShard

func CreateGraphTestOneAsyncCallFailNoCallbackCrossShard() *TestCallGraph

CreateGraphTestOneAsyncCallFailNoCallbackCrossShard -

func CreateGraphTestOneAsyncCallNoCallback

func CreateGraphTestOneAsyncCallNoCallback() *TestCallGraph

CreateGraphTestOneAsyncCallNoCallback -

func CreateGraphTestOneAsyncCallNoCallbackCrossShard

func CreateGraphTestOneAsyncCallNoCallbackCrossShard() *TestCallGraph

CreateGraphTestOneAsyncCallNoCallbackCrossShard -

func CreateGraphTestOneAsyncCallNoCallbackFail

func CreateGraphTestOneAsyncCallNoCallbackFail() *TestCallGraph

CreateGraphTestOneAsyncCallNoCallbackFail -

func CreateGraphTestOneAsyncCallbackFail

func CreateGraphTestOneAsyncCallbackFail() *TestCallGraph

CreateGraphTestOneAsyncCallbackFail -

func CreateGraphTestOneAsyncCallbackFailCrossShard

func CreateGraphTestOneAsyncCallbackFailCrossShard() *TestCallGraph

CreateGraphTestOneAsyncCallbackFailCrossShard -

func CreateGraphTestSameContractWithDifferentSubCallsCrossCross

func CreateGraphTestSameContractWithDifferentSubCallsCrossCross() *TestCallGraph

CreateGraphTestSameContractWithDifferentSubCallsCrossCross -

func CreateGraphTestSameContractWithDifferentSubCallsCrossLocal

func CreateGraphTestSameContractWithDifferentSubCallsCrossLocal() *TestCallGraph

CreateGraphTestSameContractWithDifferentSubCallsCrossLocal -

func CreateGraphTestSameContractWithDifferentSubCallsLocalCross

func CreateGraphTestSameContractWithDifferentSubCallsLocalCross() *TestCallGraph

CreateGraphTestSameContractWithDifferentSubCallsLocalCross -

func CreateGraphTestSameContractWithDifferentSubCallsLocalLocal

func CreateGraphTestSameContractWithDifferentSubCallsLocalLocal() *TestCallGraph

CreateGraphTestSameContractWithDifferentSubCallsLocalLocal -

func CreateGraphTestSyncAndAsync1

func CreateGraphTestSyncAndAsync1() *TestCallGraph

CreateGraphTestSyncAndAsync1 -

func CreateGraphTestSyncAndAsync10

func CreateGraphTestSyncAndAsync10() *TestCallGraph

CreateGraphTestSyncAndAsync10 -

func CreateGraphTestSyncAndAsync11

func CreateGraphTestSyncAndAsync11() *TestCallGraph

CreateGraphTestSyncAndAsync11 -

func CreateGraphTestSyncAndAsync2

func CreateGraphTestSyncAndAsync2() *TestCallGraph

CreateGraphTestSyncAndAsync2 -

func CreateGraphTestSyncAndAsync3

func CreateGraphTestSyncAndAsync3() *TestCallGraph

CreateGraphTestSyncAndAsync3 -

func CreateGraphTestSyncAndAsync4

func CreateGraphTestSyncAndAsync4() *TestCallGraph

CreateGraphTestSyncAndAsync4 -

func CreateGraphTestSyncAndAsync5

func CreateGraphTestSyncAndAsync5() *TestCallGraph

CreateGraphTestSyncAndAsync5 -

func CreateGraphTestSyncAndAsync6

func CreateGraphTestSyncAndAsync6() *TestCallGraph

CreateGraphTestSyncAndAsync6 -

func CreateGraphTestSyncAndAsync7

func CreateGraphTestSyncAndAsync7() *TestCallGraph

CreateGraphTestSyncAndAsync7 -

func CreateGraphTestSyncAndAsync8

func CreateGraphTestSyncAndAsync8() *TestCallGraph

CreateGraphTestSyncAndAsync8 -

func CreateGraphTestSyncAndAsync9

func CreateGraphTestSyncAndAsync9() *TestCallGraph

CreateGraphTestSyncAndAsync9 -

func CreateGraphTestSyncCalls

func CreateGraphTestSyncCalls() *TestCallGraph

CreateGraphTestSyncCalls -

func CreateGraphTestSyncCalls2

func CreateGraphTestSyncCalls2() *TestCallGraph

CreateGraphTestSyncCalls2 -

func CreateGraphTestSyncCallsFailPropagation

func CreateGraphTestSyncCallsFailPropagation() *TestCallGraph

CreateGraphTestSyncCallsFailPropagation -

func CreateGraphTestTwoAsyncCalls

func CreateGraphTestTwoAsyncCalls() *TestCallGraph

CreateGraphTestTwoAsyncCalls -

func CreateGraphTestTwoAsyncCallsBothCallbacksFail

func CreateGraphTestTwoAsyncCallsBothCallbacksFail() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothCallbacksFail -

func CreateGraphTestTwoAsyncCallsBothCallbacksFailCrossLocal

func CreateGraphTestTwoAsyncCallsBothCallbacksFailCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothCallbacksFailCrossLocal -

func CreateGraphTestTwoAsyncCallsBothCallbacksFailCrossShard

func CreateGraphTestTwoAsyncCallsBothCallbacksFailCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothCallbacksFailCrossShard -

func CreateGraphTestTwoAsyncCallsBothCallbacksFailLocalCross

func CreateGraphTestTwoAsyncCallsBothCallbacksFailLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothCallbacksFailLocalCross -

func CreateGraphTestTwoAsyncCallsBothFail

func CreateGraphTestTwoAsyncCallsBothFail() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothFail -

func CreateGraphTestTwoAsyncCallsBothFailCrossLocal

func CreateGraphTestTwoAsyncCallsBothFailCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothFailCrossLocal -

func CreateGraphTestTwoAsyncCallsBothFailCrossShard

func CreateGraphTestTwoAsyncCallsBothFailCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothFailCrossShard -

func CreateGraphTestTwoAsyncCallsBothFailLocalCross

func CreateGraphTestTwoAsyncCallsBothFailLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsBothFailLocalCross -

func CreateGraphTestTwoAsyncCallsCrossLocal

func CreateGraphTestTwoAsyncCallsCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsCrossLocal -

func CreateGraphTestTwoAsyncCallsCrossShard

func CreateGraphTestTwoAsyncCallsCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsCrossShard -

func CreateGraphTestTwoAsyncCallsFirstCallbackFail

func CreateGraphTestTwoAsyncCallsFirstCallbackFail() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstCallbackFail -

func CreateGraphTestTwoAsyncCallsFirstCallbackFailCrossLocal

func CreateGraphTestTwoAsyncCallsFirstCallbackFailCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstCallbackFailCrossLocal -

func CreateGraphTestTwoAsyncCallsFirstCallbackFailCrossShard

func CreateGraphTestTwoAsyncCallsFirstCallbackFailCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstCallbackFailCrossShard -

func CreateGraphTestTwoAsyncCallsFirstCallbackFailLocalCross

func CreateGraphTestTwoAsyncCallsFirstCallbackFailLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstCallbackFailLocalCross -

func CreateGraphTestTwoAsyncCallsFirstFail

func CreateGraphTestTwoAsyncCallsFirstFail() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstFail -

func CreateGraphTestTwoAsyncCallsFirstFailCrossLocal

func CreateGraphTestTwoAsyncCallsFirstFailCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstFailCrossLocal -

func CreateGraphTestTwoAsyncCallsFirstFailCrossShard

func CreateGraphTestTwoAsyncCallsFirstFailCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstFailCrossShard -

func CreateGraphTestTwoAsyncCallsFirstFailLocalCross

func CreateGraphTestTwoAsyncCallsFirstFailLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstFailLocalCross -

func CreateGraphTestTwoAsyncCallsFirstNoCallback

func CreateGraphTestTwoAsyncCallsFirstNoCallback() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstNoCallback -

func CreateGraphTestTwoAsyncCallsFirstNoCallbackCrossLocal

func CreateGraphTestTwoAsyncCallsFirstNoCallbackCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstNoCallbackCrossLocal -

func CreateGraphTestTwoAsyncCallsFirstNoCallbackCrossShard

func CreateGraphTestTwoAsyncCallsFirstNoCallbackCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsFirstNoCallbackCrossShard -

func CreateGraphTestTwoAsyncCallsLocalCross

func CreateGraphTestTwoAsyncCallsLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsLocalCross -

func CreateGraphTestTwoAsyncCallsSecondCallbackFail

func CreateGraphTestTwoAsyncCallsSecondCallbackFail() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondCallbackFail -

func CreateGraphTestTwoAsyncCallsSecondCallbackFailCrossLocal

func CreateGraphTestTwoAsyncCallsSecondCallbackFailCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondCallbackFailCrossLocal -

func CreateGraphTestTwoAsyncCallsSecondCallbackFailCrossShard

func CreateGraphTestTwoAsyncCallsSecondCallbackFailCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondCallbackFailCrossShard -

func CreateGraphTestTwoAsyncCallsSecondCallbackFailLocalCross

func CreateGraphTestTwoAsyncCallsSecondCallbackFailLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondCallbackFailLocalCross -

func CreateGraphTestTwoAsyncCallsSecondFail

func CreateGraphTestTwoAsyncCallsSecondFail() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondFail -

func CreateGraphTestTwoAsyncCallsSecondFailCrossLocal

func CreateGraphTestTwoAsyncCallsSecondFailCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondFailCrossLocal -

func CreateGraphTestTwoAsyncCallsSecondFailCrossShard

func CreateGraphTestTwoAsyncCallsSecondFailCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondFailCrossShard -

func CreateGraphTestTwoAsyncCallsSecondFailLocalCross

func CreateGraphTestTwoAsyncCallsSecondFailLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondFailLocalCross -

func CreateGraphTestTwoAsyncCallsSecondNoCallback

func CreateGraphTestTwoAsyncCallsSecondNoCallback() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondNoCallback -

func CreateGraphTestTwoAsyncCallsSecondNoCallbackCrossLocal

func CreateGraphTestTwoAsyncCallsSecondNoCallbackCrossLocal() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondNoCallbackCrossLocal -

func CreateGraphTestTwoAsyncCallsSecondNoCallbackCrossShard

func CreateGraphTestTwoAsyncCallsSecondNoCallbackCrossShard() *TestCallGraph

CreateGraphTestTwoAsyncCallsSecondNoCallbackCrossShard -

func CreateGraphTestTwoAsyncFirstNoCallbackCallsLocalCross

func CreateGraphTestTwoAsyncFirstNoCallbackCallsLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncFirstNoCallbackCallsLocalCross -

func CreateGraphTestTwoAsyncSecondNoCallbackCallsLocalCross

func CreateGraphTestTwoAsyncSecondNoCallbackCallsLocalCross() *TestCallGraph

CreateGraphTestTwoAsyncSecondNoCallbackCallsLocalCross -

func CreateTestCallGraph

func CreateTestCallGraph() *TestCallGraph

CreateTestCallGraph is the initial build metohd for the call graph

func MakeGraphAndImage

func MakeGraphAndImage(graph *TestCallGraph) *TestCallGraph

MakeGraphAndImage -

func (*TestCallGraph) AddAsyncCrossShardEdge

func (graph *TestCallGraph) AddAsyncCrossShardEdge(from *TestCallNode, to *TestCallNode, callBack string, group string) *TestCallEdge

AddAsyncCrossShardEdge adds a local async call edge between two nodes of the call graph

func (*TestCallGraph) AddAsyncEdge

func (graph *TestCallGraph) AddAsyncEdge(from *TestCallNode, to *TestCallNode, callBack string, group string) *TestCallEdge

AddAsyncEdge adds a local async call edge between two nodes of the call graph

func (*TestCallGraph) AddNode

func (graph *TestCallGraph) AddNode(contractID string, functionName string) *TestCallNode

AddNode adds a node to the call graph

func (*TestCallGraph) AddNodeCopy

func (graph *TestCallGraph) AddNodeCopy(node *TestCallNode) *TestCallNode

AddNodeCopy adds a copy of a node to the node list

func (*TestCallGraph) AddStartNode

func (graph *TestCallGraph) AddStartNode(contractID string, functionName string, gasLimit uint64, gasUsed uint64) *TestCallNode

AddStartNode adds the start node of the call graph

func (*TestCallGraph) AddSyncEdge

func (graph *TestCallGraph) AddSyncEdge(from *TestCallNode, to *TestCallNode) *TestCallEdge

AddSyncEdge adds a labeled sync call edge between two nodes of the call graph

func (*TestCallGraph) AssignExecutionRounds

func (graph *TestCallGraph) AssignExecutionRounds(_ *testing.T)

AssignExecutionRounds -

func (*TestCallGraph) ComputeGasGraphFromExecutionGraph

func (graph *TestCallGraph) ComputeGasGraphFromExecutionGraph() *TestCallGraph

ComputeGasGraphFromExecutionGraph - creates a gas graph from an execution graph

func (*TestCallGraph) ComputeRemainingGasAfterCallbacks

func (graph *TestCallGraph) ComputeRemainingGasAfterCallbacks()

ComputeRemainingGasAfterCallbacks -

func (*TestCallGraph) ComputeRemainingGasBeforeCallbacks

func (graph *TestCallGraph) ComputeRemainingGasBeforeCallbacks(_ *testing.T)

ComputeRemainingGasBeforeCallbacks - adjusts the gas graph / tree remaining gas info using the gas provided to children this will not take into consideration callback nodes that don't have provided gas info computed yet (see ComputeGasStepByStep)

func (*TestCallGraph) CreateExecutionGraphFromCallGraph

func (graph *TestCallGraph) CreateExecutionGraphFromCallGraph() *TestCallGraph

CreateExecutionGraphFromCallGraph - creates an execution graph from the call graph

func (*TestCallGraph) DfsFromNodeUntilFailures

func (graph *TestCallGraph) DfsFromNodeUntilFailures(parent *TestCallNode, node *TestCallNode, incomingEdge *TestCallEdge, path []*TestCallNode,
	processNode processNodeFunc,
	visits map[uint]bool) *TestCallNode

DfsFromNodeUntilFailures will stop DFS going deeper at first encountered fail

func (*TestCallGraph) DfsGraph

func (graph *TestCallGraph) DfsGraph(
	processNode processNodeFunc,
	followCrossShardEdges bool)

DfsGraph a standard DFS traversal for the call graph

func (*TestCallGraph) DfsGraphFromNode

func (graph *TestCallGraph) DfsGraphFromNode(startNode *TestCallNode, processNode processNodeFunc,
	visits map[uint]bool,
	followCrossShardEdges bool)

DfsGraphFromNode standard DFS starting from a node

func (*TestCallGraph) DfsGraphFromNodePostOrder

func (graph *TestCallGraph) DfsGraphFromNodePostOrder(startNode *TestCallNode, processNode func(*TestCallNode, *TestCallNode, *TestCallEdge) *TestCallNode)

DfsGraphFromNodePostOrder - standard post order DFS

func (*TestCallGraph) FindNode

func (graph *TestCallGraph) FindNode(contractAddress []byte, functionName string) *TestCallNode

FindNode finds the corresponding node in the call graph

func (*TestCallGraph) GetStartNode

func (graph *TestCallGraph) GetStartNode() *TestCallNode

GetStartNode - start node getter

func (*TestCallGraph) PropagateSyncFailures

func (graph *TestCallGraph) PropagateSyncFailures()

PropagateSyncFailures -

type TestCallNode

type TestCallNode struct {
	ID uint

	// entry point in call graph
	IsStartNode bool

	// node payload
	Call *TestCall
	// connected nodes
	AdjacentEdges []*TestCallEdge

	NonGasEdgeCounter int64

	// labels used only for visualization & debugging
	VisualLabel string
	// needs to be unique (will be in te form of contract_function_index)
	Label string

	// back pointer / "edge" to parent for trees (not part of the actual graph, not traversed)
	Parent       *TestCallNode
	IncomingEdge *TestCallEdge

	// info used for gas assertions
	// set from an incoming edge edge
	GasLimit  uint64
	GasUsed   uint64
	GasLocked uint64

	// computed info
	ExecutionRound           int
	MaxSubtreeExecutionRound int
	GasRemaining             uint64
	GasAccumulated           uint64

	// set automaticaly when the test is run
	CrtTxHash []byte

	ShardID uint32

	/*
		for some processes we don't have a tree traversal, but just an execution order,
		so we need this info copied from the incoming edge
	*/
	// a failed edge points to this node
	Fail bool
	// error of the failed edge
	ErrFail error
}

TestCallNode is a node in the call graph

func (*TestCallNode) GetEdges

func (node *TestCallNode) GetEdges() []*TestCallEdge

GetEdges gets the outgoing edges of the node

func (*TestCallNode) GetIncomingEdgeType

func (node *TestCallNode) GetIncomingEdgeType() TestCallEdgeType

GetIncomingEdgeType returns the type of the incoming edge (for a tree)

func (*TestCallNode) HasCallback

func (node *TestCallNode) HasCallback() bool

HasCallback -

func (*TestCallNode) HasFailSyncEdge

func (node *TestCallNode) HasFailSyncEdge() bool

HasFailSyncEdge -

func (*TestCallNode) IsAsync

func (node *TestCallNode) IsAsync() bool

IsAsync -

func (*TestCallNode) IsCallback

func (node *TestCallNode) IsCallback() bool

IsCallback -

func (*TestCallNode) IsGasLeaf

func (node *TestCallNode) IsGasLeaf() bool

IsGasLeaf returns true if the node as any adjacent nodes and is "*" node

func (*TestCallNode) IsIncomingEdgeFail

func (node *TestCallNode) IsIncomingEdgeFail() bool

IsIncomingEdgeFail -

func (*TestCallNode) IsLeaf

func (node *TestCallNode) IsLeaf() bool

IsLeaf returns true if the node as any adjacent nodes

func (*TestCallNode) IsSync

func (node *TestCallNode) IsSync() bool

IsSync -

func (*TestCallNode) WillNotExecute

func (node *TestCallNode) WillNotExecute() bool

WillNotExecute returns if node will execute based on execution round

type TestCallPath

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

TestCallPath a path in a tree, len(edges) = len(nodes) - 1

type TestConfig

type TestConfig struct {
	ParentAddress     []byte
	ChildAddress      []byte
	NephewAddress     []byte
	ThirdPartyAddress []byte
	VaultAddress      []byte

	GasProvided           uint64
	GasProvidedToChild    uint64
	GasProvidedToCallback uint64
	GasUsedByParent       uint64
	GasUsedByChild        uint64
	GasUsedByCallback     uint64
	GasLockCost           uint64
	GasToLock             uint64

	ParentBalance int64
	ChildBalance  int64

	TransferFromParentToChild int64
	TransferToThirdParty      int64
	TransferToVault           int64
	TransferFromChildToParent int64

	ESDTTokensToTransfer         uint64
	CallbackESDTTokensToTransfer uint64

	ChildCalls          int
	RecursiveChildCalls int

	DeployedContractAddress []byte
	GasUsedByInit           uint64
	GasProvidedForInit      uint64
	AsyncCallStepCost       uint64
	AoTPreparePerByteCost   uint64
	CompilePerByteCost      uint64

	ContractToBeUpdatedAddress []byte
	Owner                      []byte
	IsFlagEnabled              bool
	HasCallback                bool
	CallbackFails              bool

	IsLegacyAsync   bool
	SuccessCallback string
	ErrorCallback   string
}

TestConfig is configuration for async call tests

func (*TestConfig) GetChildAddress

func (config *TestConfig) GetChildAddress() []byte

GetChildAddress -

func (*TestConfig) GetThirdPartyAddress

func (config *TestConfig) GetThirdPartyAddress() []byte

GetThirdPartyAddress -

func (*TestConfig) GetVaultAddress

func (config *TestConfig) GetVaultAddress() []byte

GetVaultAddress -

type TestHostBuilder

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

TestHostBuilder allows tests to configure and initialize the VM host and blockhain mock on which they operate.

func NewTestHostBuilder

func NewTestHostBuilder(tb testing.TB) *TestHostBuilder

NewTestHostBuilder commences a test host builder pattern.

func (*TestHostBuilder) Build

func (thb *TestHostBuilder) Build() vmhost.VMHost

Build initializes the VM host with all configured options.

func (*TestHostBuilder) WithBlockchainHook

func (thb *TestHostBuilder) WithBlockchainHook(blockchainHook vmcommon.BlockchainHook) *TestHostBuilder

WithBlockchainHook sets a pre-built blockchain hook for the VM to work with.

func (*TestHostBuilder) WithBuiltinFunctions

func (thb *TestHostBuilder) WithBuiltinFunctions() *TestHostBuilder

WithBuiltinFunctions sets up builtin functions in the blockchain hook. Only works if the blockchain hook is of type worldmock.MockWorld.

func (*TestHostBuilder) WithExecutorFactory

func (thb *TestHostBuilder) WithExecutorFactory(executorFactory executor.ExecutorAbstractFactory) *TestHostBuilder

WithExecutorFactory allows tests to choose what executor to use.

func (*TestHostBuilder) WithExecutorLogs

func (thb *TestHostBuilder) WithExecutorLogs(executorLogger executorwrapper.ExecutorLogger) *TestHostBuilder

WithExecutorLogs sets an ExecutorLogger, which wraps the existing OverrideVMExecutor

func (*TestHostBuilder) WithGasSchedule

func (thb *TestHostBuilder) WithGasSchedule(gasSchedule config.GasScheduleMap) *TestHostBuilder

WithGasSchedule allows tests to use the gas costs. The default is config.MakeGasMapForTests().

func (*TestHostBuilder) WithWasmerSIGSEGVPassthrough

func (thb *TestHostBuilder) WithWasmerSIGSEGVPassthrough(wasmerSIGSEGVPassthrough bool) *TestHostBuilder

WithWasmerSIGSEGVPassthrough allows tests to configure the WasmerSIGSEGVPassthrough flag.

type TestType

type TestType int

TestType indicates whether the test is a SC call test or a SC creation test

const (
	// RunTest indicates a test with SC calls
	RunTest TestType = iota

	// CreateTest indicates a test with SC creation
	CreateTest
)

type TransferEntry

type TransferEntry struct {
	vmcommon.OutputTransfer
	// contains filtered or unexported fields
}

TransferEntry holds the data for an output transfer assertion

func CreateTransferEntry

func CreateTransferEntry(senderAddress []byte, receiverAddress []byte, index uint32) *TransferEntry

CreateTransferEntry creates the data for an output transfer assertion

func (*TransferEntry) IgnoreDataItems

func (transferEntry *TransferEntry) IgnoreDataItems(ignoredDataArguments ...int) *TransferEntry

IgnoreDataItems specifies data arguments to be ignored in assertions

func (*TransferEntry) WithCallType

func (transferEntry *TransferEntry) WithCallType(callType vm.CallType) *TransferEntry

WithCallType create sets the data for an output transfer assertion

func (*TransferEntry) WithData

func (transferEntry *TransferEntry) WithData(data []byte) *TransferEntry

WithData create sets the data for an output transfer assertion

func (*TransferEntry) WithGasLimit

func (transferEntry *TransferEntry) WithGasLimit(gas uint64) *TransferEntry

WithGasLimit create sets the data for an output transfer assertion

func (*TransferEntry) WithGasLocked

func (transferEntry *TransferEntry) WithGasLocked(gas uint64) *TransferEntry

WithGasLocked create sets the data for an output transfer assertion

func (*TransferEntry) WithValue

func (transferEntry *TransferEntry) WithValue(value *big.Int) TransferEntry

WithValue create sets the value for an output transfer assertion

type VMOutputVerifier

type VMOutputVerifier struct {
	VmOutput  *vmcommon.VMOutput
	AllErrors vmhost.WrappableError
	T         testing.TB
}

VMOutputVerifier holds the output to be verified

func NewVMOutputVerifier

func NewVMOutputVerifier(t testing.TB, vmOutput *vmcommon.VMOutput, err error) *VMOutputVerifier

NewVMOutputVerifier builds a new verifier

func NewVMOutputVerifierWithAllErrors

func NewVMOutputVerifierWithAllErrors(t testing.TB, vmOutput *vmcommon.VMOutput, err error, allErrors error) *VMOutputVerifier

NewVMOutputVerifierWithAllErrors builds a new verifier with all errors included

func (*VMOutputVerifier) Balance

func (v *VMOutputVerifier) Balance(address []byte, balance int64) *VMOutputVerifier

Balance verifies if Balance of the specified account is the same as the provided one

func (*VMOutputVerifier) BalanceDelta

func (v *VMOutputVerifier) BalanceDelta(address []byte, balanceDelta int64) *VMOutputVerifier

BalanceDelta verifies if BalanceDelta of the specified account is the same as the provided one

func (*VMOutputVerifier) BytesAddedToStorage

func (v *VMOutputVerifier) BytesAddedToStorage(address []byte, bytesAdded int) *VMOutputVerifier

BytesAddedToStorage verifies the number of bytes added to storage

func (*VMOutputVerifier) BytesDeletedFromStorage

func (v *VMOutputVerifier) BytesDeletedFromStorage(address []byte, bytesDelted int) *VMOutputVerifier

BytesDeletedFromStorage verifies the number of bytes deleted from storage

func (*VMOutputVerifier) Code

func (v *VMOutputVerifier) Code(address []byte, code []byte) *VMOutputVerifier

Code verifies if Code of the specified account is the same as the provided one

func (*VMOutputVerifier) CodeDeployerAddress

func (v *VMOutputVerifier) CodeDeployerAddress(address []byte, codeDeployerAddress []byte) *VMOutputVerifier

CodeDeployerAddress if CodeDeployerAddress of the specified account is the same as the provided one

func (*VMOutputVerifier) CodeMetadata

func (v *VMOutputVerifier) CodeMetadata(address []byte, codeMetadata []byte) *VMOutputVerifier

CodeMetadata if CodeMetadata of the specified account is the same as the provided one

func (*VMOutputVerifier) ContractInvalid

func (v *VMOutputVerifier) ContractInvalid() *VMOutputVerifier

ContractInvalid verifies if return code is vmcommon.ContractInvalid

func (*VMOutputVerifier) ContractNotFound

func (v *VMOutputVerifier) ContractNotFound() *VMOutputVerifier

ContractNotFound verifies if return code is vmcommon.ContractNotFound

func (*VMOutputVerifier) DeletedAccounts

func (v *VMOutputVerifier) DeletedAccounts(deletedAccounts ...[]byte) *VMOutputVerifier

DeletedAccounts verifies if DeletedAccounts is the same as the provided one

func (*VMOutputVerifier) ExecutionFailed

func (v *VMOutputVerifier) ExecutionFailed() *VMOutputVerifier

ExecutionFailed verifies if return code is vmcommon.ExecutionFailed

func (*VMOutputVerifier) FunctionNotFound

func (v *VMOutputVerifier) FunctionNotFound() *VMOutputVerifier

FunctionNotFound verifies if return code is vmcommon.FunctionNotFound

func (*VMOutputVerifier) GasRemaining

func (v *VMOutputVerifier) GasRemaining(gas uint64) *VMOutputVerifier

GasRemaining verifies if GasRemaining of the specified account is the same as the provided one

func (*VMOutputVerifier) GasUsed

func (v *VMOutputVerifier) GasUsed(address []byte, gas uint64) *VMOutputVerifier

GasUsed verifies if GasUsed of the specified account is the same as the provided one

func (*VMOutputVerifier) HasRuntimeErrorAndInfo

func (v *VMOutputVerifier) HasRuntimeErrorAndInfo(message string, otherInfo string) *VMOutputVerifier

HasRuntimeErrorAndInfo verifies if the provided errors are present in the runtime context

func (*VMOutputVerifier) HasRuntimeErrors

func (v *VMOutputVerifier) HasRuntimeErrors(messages ...string) *VMOutputVerifier

HasRuntimeErrors verifies if the provided errors are present in the runtime context

func (*VMOutputVerifier) Logs

Logs verifies if Logs is the same as the provided one

func (*VMOutputVerifier) Nonce

func (v *VMOutputVerifier) Nonce(address []byte, nonce uint64) *VMOutputVerifier

Nonce verifies if Nonce of the specified account is the same as the provided one

func (*VMOutputVerifier) Ok

Ok verifies if return code is vmcommon.Ok

func (*VMOutputVerifier) OutOfGas

func (v *VMOutputVerifier) OutOfGas() *VMOutputVerifier

OutOfGas verifies if return code is vmcommon.OutOfGas

func (*VMOutputVerifier) Print

func (v *VMOutputVerifier) Print() *VMOutputVerifier

Print writes the contents of the VMOutput with log.Trace()

func (*VMOutputVerifier) ReturnCode

ReturnCode verifies if ReturnCode of output is the same as the provided one

func (*VMOutputVerifier) ReturnData

func (v *VMOutputVerifier) ReturnData(returnData ...[]byte) *VMOutputVerifier

ReturnData verifies if ReturnData is the same as the provided one

func (*VMOutputVerifier) ReturnDataContains

func (v *VMOutputVerifier) ReturnDataContains(element []byte) *VMOutputVerifier

ReturnDataContains verifies that ReturnData contains the provided element

func (*VMOutputVerifier) ReturnDataDoesNotContain

func (v *VMOutputVerifier) ReturnDataDoesNotContain(element []byte) *VMOutputVerifier

ReturnDataDoesNotContain verifies that ReturnData does not contain the provided element

func (*VMOutputVerifier) ReturnMessage

func (v *VMOutputVerifier) ReturnMessage(message string) *VMOutputVerifier

ReturnMessage verifies if ReturnMessage of output is the same as the provided one

func (*VMOutputVerifier) ReturnMessageContains

func (v *VMOutputVerifier) ReturnMessageContains(message string) *VMOutputVerifier

ReturnMessageContains verifies if ReturnMessage of output contains the provided one

func (*VMOutputVerifier) Storage

func (v *VMOutputVerifier) Storage(expectedEntries ...StoreEntry) *VMOutputVerifier

Storage verifies if StorageUpdate(s) for the speficied accounts are the same as the provided ones

func (*VMOutputVerifier) Transfers

func (v *VMOutputVerifier) Transfers(transfers ...TransferEntry) *VMOutputVerifier

Transfers verifies if OutputTransfer(s) for the speficied accounts are the same as the provided ones

func (*VMOutputVerifier) UserError

func (v *VMOutputVerifier) UserError() *VMOutputVerifier

UserError verifies if return code is vmcommon.UserError

Directories

Path Synopsis
Package testexecutor provides with a default executor for testing
Package testexecutor provides with a default executor for testing

Jump to

Keyboard shortcuts

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