testcommon

package
v1.4.98 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package testcommon contains utility code for writing tests

Index

Constants

View Source
const AddressSize = 32

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

Variables

View Source
var ChildAddress = MakeTestSCAddress("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 GasProvided = uint64(1000000)

GasProvided value exposed for test usage

View Source
var NephewAddress = MakeTestSCAddress("NephewAddress")

NephewAddress is an exposed value to use in tests

View Source
var ParentAddress = MakeTestSCAddress("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 ThirdPartyAddress = []byte("\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0fthirdPartyAddress.....")

ThirdPartyAddress value exposed for test usage

View Source
var UserAddress = []byte("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

Functions

func AddNewOutputAccount

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

AddNewOutputAccount 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 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 DefaultTestVM

func DefaultTestVM(tb testing.TB, blockchain vmcommon.BlockchainHook) vmhost.VMHost

DefaultTestVM creates a host configured with a blockchain hook

func DefaultTestVMForCall

func DefaultTestVMForCall(tb testing.TB, code []byte, balance *big.Int) (vmhost.VMHost, *contextmock.BlockchainHookStub)

DefaultTestVMForCall creates a BlockchainHookStub

func DefaultTestVMForCallSigSegv

func DefaultTestVMForCallSigSegv(tb testing.TB, code []byte, balance *big.Int) (vmhost.VMHost, *contextmock.BlockchainHookStub)

DefaultTestVMForCallSigSegv creates a BlockchainHookStub and a host

func DefaultTestVMForCallWithInstanceMocks

func DefaultTestVMForCallWithInstanceMocks(tb testing.TB) (vmhost.VMHost, *worldmock.MockWorld, *contextmock.InstanceBuilderMock)

DefaultTestVMForCallWithInstanceMocks creates an InstanceBuilderMock

func DefaultTestVMForCallWithInstanceRecorderMock

func DefaultTestVMForCallWithInstanceRecorderMock(tb testing.TB, code []byte, balance *big.Int) (vmhost.VMHost, *contextmock.InstanceBuilderRecorderMock)

DefaultTestVMForCallWithInstanceRecorderMock creates an InstanceBuilderRecorderMock

func DefaultTestVMForCallWithWorldMock

func DefaultTestVMForCallWithWorldMock(tb testing.TB, code []byte, balance *big.Int) (vmhost.VMHost, *worldmock.MockWorld)

DefaultTestVMForCallWithWorldMock creates a MockWorld

func DefaultTestVMForDeployment

func DefaultTestVMForDeployment(t *testing.T, _ uint64, newAddress []byte) (vmhost.VMHost, *contextmock.BlockchainHookStub)

DefaultTestVMForDeployment creates an VM vmHost configured for testing deployments

func DefaultTestVMForTwoSCs

func DefaultTestVMForTwoSCs(
	t *testing.T,
	parentCode []byte,
	childCode []byte,
	parentSCBalance *big.Int,
	childSCBalance *big.Int,
) (vmhost.VMHost, *contextmock.BlockchainHookStub)

DefaultTestVMForTwoSCs creates an VM vmHost configured for testing calls between 2 SmartContracts

func DefaultTestVMWithGasSchedule

func DefaultTestVMWithGasSchedule(
	tb testing.TB,
	blockchain vmcommon.BlockchainHook,
	customGasSchedule config.GasScheduleMap,
	wasmerSIGSEGVPassthrough bool,
) vmhost.VMHost

DefaultTestVMWithGasSchedule creates a host with the provided blockchain hook and gas schedule

func DefaultTestVMWithWorldMock

func DefaultTestVMWithWorldMock(tb testing.TB) (vmhost.VMHost, *worldmock.MockWorld)

DefaultTestVMWithWorldMock creates a host configured with a mock world

func DefaultTestVMWithWorldMockWithGasSchedule

func DefaultTestVMWithWorldMockWithGasSchedule(tb testing.TB, customGasSchedule config.GasScheduleMap) (vmhost.VMHost, *worldmock.MockWorld)

DefaultTestVMWithWorldMockWithGasSchedule creates a host configured with a mock world

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 MakeTestSCAddress

func MakeTestSCAddress(identifier string) []byte

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

func MakeVMOutput

func MakeVMOutput() *vmcommon.VMOutput

MakeVMOutput creates a vmcommon.VMOutput struct with default values

func SimpleWasteGasMockMethod

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

SimpleWasteGasMockMethod is a simple waste gas mock method

Types

type ContractCallInputBuilder

type ContractCallInputBuilder struct {
	vmcommon.ContractCallInput
}

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) WithArguments

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

WithArguments provides the 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) WithGasProvided

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

WithGasProvided provides the gas of 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) WithGasProvided

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

WithGasProvided provides the GasProvided for a ContractCreateInputBuilder

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) WithConfig

func (mockSC *InstanceTestSmartContract) WithConfig(config interface{}) *InstanceTestSmartContract

WithConfig provides the config object for the InstanceTestSmartContract

type InstancesTestTemplate

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

InstancesTestTemplate holds the data to build a contract call test

func BuildInstanceCallTest

func BuildInstanceCallTest(tb testing.TB) *InstancesTestTemplate

BuildInstanceCallTest starts the building process for a contract call test

func (*InstancesTestTemplate) AndAssertResults

func (callerTest *InstancesTestTemplate) AndAssertResults(assertResults func(vmhost.VMHost, *contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResults starts the test and asserts the results

func (*InstancesTestTemplate) AndAssertResultsWithoutReset

func (callerTest *InstancesTestTemplate) AndAssertResultsWithoutReset(assertResults func(vmhost.VMHost, *contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResultsWithoutReset starts the test and asserts the results

func (*InstancesTestTemplate) GetVMHost

func (callerTest *InstancesTestTemplate) GetVMHost() vmhost.VMHost

GetVMHost returns the host instantiated in this test template

func (*InstancesTestTemplate) WithContracts

func (callerTest *InstancesTestTemplate) WithContracts(usedContracts ...*InstanceTestSmartContract) *InstancesTestTemplate

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

func (*InstancesTestTemplate) WithGasSchedule

func (callerTest *InstancesTestTemplate) WithGasSchedule(gasSchedule config.GasScheduleMap) *InstancesTestTemplate

WithGasSchedule provides gas schedule for the test

func (*InstancesTestTemplate) WithInput

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

func (*InstancesTestTemplate) WithSetup

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

func (*InstancesTestTemplate) WithWasmerSIGSEGVPassthrough

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

WithWasmerSIGSEGVPassthrough sets the wasmerSIGSEGVPassthrough flag

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 func(world *worldmock.MockWorld, verify *VMOutputVerifier))

AndAssertResults provides the function that will aserts the results

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 (*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 interface{}) *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

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) 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 TestCreateTemplateConfig

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

TestCreateTemplateConfig holds the data to build a contract creation test

func BuildInstanceCreatorTest

func BuildInstanceCreatorTest(t *testing.T) *TestCreateTemplateConfig

BuildInstanceCreatorTest starts the building process for a contract creation test

func (*TestCreateTemplateConfig) AndAssertResults

func (callerTest *TestCreateTemplateConfig) AndAssertResults(assertResults func(*contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResults provides the function that will aserts the results

func (*TestCreateTemplateConfig) AndAssertResultsWithoutReset

func (callerTest *TestCreateTemplateConfig) AndAssertResultsWithoutReset(assertResults func(*contextmock.BlockchainHookStub, *VMOutputVerifier))

AndAssertResultsWithoutReset provides the function that will aserts the results

func (*TestCreateTemplateConfig) WithAddress

func (callerTest *TestCreateTemplateConfig) WithAddress(address []byte) *TestCreateTemplateConfig

WithAddress provides the address for a TestCreateTemplateConfig

func (*TestCreateTemplateConfig) WithInput

func (callerTest *TestCreateTemplateConfig) WithInput(input *vmcommon.ContractCreateInput) *TestCreateTemplateConfig

WithInput provides the ContractCreateInput for a TestCreateTemplateConfig

func (*TestCreateTemplateConfig) WithSetup

WithSetup provides the setup function for a TestCreateTemplateConfig

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) *TransferEntry

CreateTransferEntry creates the data for an output transfer assertion

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) 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) 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) 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

Jump to

Keyboard shortcuts

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