host

package
v1.3.0-rel Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const AddressSize = 32

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

Variables

View Source
var MaximumWasmerInstanceCount = uint64(10)

MaximumWasmerInstanceCount represents the maximum number of Wasmer instances that can be active at the same time

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.

Functions

func AddFinishData added in v0.3.8

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

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

func AddNewOutputAccount added in v0.3.8

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 added in v1.1.2

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 BuildSCModule added in v1.2.5

func BuildSCModule(scName string, prefixToTestSCs string)

BuildSCModule invokes erdpy to build the contract into a WASM module

func DefaultTestContractCallInput added in v0.3.8

func DefaultTestContractCallInput() *vmcommon.ContractCallInput

DefaultTestContractCallInput creates a vmcommon.ContractCallInput struct with default values.

func DefaultTestContractCreateInput added in v0.3.8

func DefaultTestContractCreateInput() *vmcommon.ContractCreateInput

DefaultTestContractCreateInput creates a vmcommon.ContractCreateInput struct with default values.

func GetSCCode added in v0.3.8

func GetSCCode(fileName string) []byte

GetSCCode retrieves the bytecode of a WASM module from a file

func GetTestSCCode added in v0.3.8

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

GetTestSCCode retrieves the bytecode of a WASM testing contract

func GetTestSCCodeModule added in v1.0.1

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 LoadGasScheduleConfig added in v0.3.12

func LoadGasScheduleConfig(filepath string) (config.GasScheduleMap, error)

LoadGasScheduleConfig parses and prepares a gas schedule read from file.

func LoadTomlFileToMap added in v0.3.12

func LoadTomlFileToMap(relativePath string) (map[string]interface{}, error)

LoadTomlFileToMap opens and decodes a toml file as a map[string]interface{}

func MakeTestSCAddress added in v1.1.2

func MakeTestSCAddress(identifier string) []byte

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

func MakeVMOutput added in v0.3.8

func MakeVMOutput() *vmcommon.VMOutput

MakeVMOutput creates a vmcommon.VMOutput struct with default values

func MakeVMOutputError added in v1.2.5

func MakeVMOutputError() *vmcommon.VMOutput

MakeVMOutputError creates a vmcommon.VMOutput struct with default values for errors

func NewArwenVM

func NewArwenVM(
	blockChainHook vmcommon.BlockchainHook,
	hostParameters *arwen.VMHostParameters,
) (*vmHost, error)

NewArwenVM creates a new Arwen vmHost

func OpenFile added in v0.3.12

func OpenFile(relativePath string) (*os.File, error)

OpenFile method opens the file from given path - does not close the file

func SetStorageUpdate added in v0.3.8

func SetStorageUpdate(account *vmcommon.OutputAccount, key []byte, data []byte)

SetStorageUpdate sets a storage update to the provided vmcommon.OutputAccount

func SetStorageUpdateStrings added in v0.3.8

func SetStorageUpdateStrings(account *vmcommon.OutputAccount, key string, data string)

SetStorageUpdateStrings sets a storage update to the provided vmcommon.OutputAccount, from string arguments

func TryCatch

func TryCatch(try TryFunction, catch CatchFunction, catchFallbackMessage string)

TryCatch simulates a try/catch block using golang's recover() functionality

Types

type CatchFunction

type CatchFunction func(error)

CatchFunction corresponds to the catch() part of a try / catch block

type MockClaimBuiltin added in v1.2.10

type MockClaimBuiltin struct {
	AmountToGive int64
	GasCost      uint64
}

func (*MockClaimBuiltin) IsInterfaceNil added in v1.2.10

func (m *MockClaimBuiltin) IsInterfaceNil() bool

func (*MockClaimBuiltin) ProcessBuiltinFunction added in v1.2.10

func (m *MockClaimBuiltin) ProcessBuiltinFunction(acntSnd, _ state.UserAccountHandler, vmInput *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error)

func (*MockClaimBuiltin) SetNewGasConfig added in v1.2.10

func (m *MockClaimBuiltin) SetNewGasConfig(_ *process.GasCost)

type TryFunction

type TryFunction func()

TryFunction corresponds to the try() part of a try / catch block

type VMOutputVerifier added in v1.2.10

type VMOutputVerifier struct {
	T testing.TB
	// contains filtered or unexported fields
}

func NewVMOutputVerifier added in v1.2.10

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

func (*VMOutputVerifier) GasRemaining added in v1.2.10

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

func (*VMOutputVerifier) GasUsed added in v1.2.10

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

func (*VMOutputVerifier) Msg added in v1.2.10

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

func (*VMOutputVerifier) NoMsg added in v1.2.10

func (v *VMOutputVerifier) NoMsg() *VMOutputVerifier

func (*VMOutputVerifier) Ok added in v1.2.10

func (*VMOutputVerifier) RetCode added in v1.2.10

Jump to

Keyboard shortcuts

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