testutil

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFailingRunner = errors.New("failing VMRunner")

ErrFailingRunner error for FailingVmRunner

Functions

func TestFailOnFailingRunner

func TestFailOnFailingRunner(t *testing.T, fn interface{}, args ...interface{})

TestFailOnFailingRunner checks that function doesn't silent VMRunner error

func TestFailsWhenContractNotDeployed

func TestFailsWhenContractNotDeployed(t *testing.T, expectedError error, fn interface{}, args ...interface{})

TestFailsWhenContractNotDeployed check calls fails when contract is not registered

func TestReturnsDefaultOnFailingRunner

func TestReturnsDefaultOnFailingRunner(t *testing.T, defaultValue interface{}, fn interface{}, args ...interface{})

TestReturnsDefaultOnFailingRunner checks that function will return a default value if there's an error on VMRunner

Types

type BlockchainParametersMock

type BlockchainParametersMock struct {
	ContractMock

	MinimumVersion                             params.VersionInfo
	BlockGasLimitValue                         *big.Int
	LookbackWindow                             *big.Int
	IntrinsicGasForAlternativeFeeCurrencyValue *big.Int
}

func NewBlockchainParametersMock

func NewBlockchainParametersMock() *BlockchainParametersMock

func (*BlockchainParametersMock) BlockGasLimit

func (bp *BlockchainParametersMock) BlockGasLimit() *big.Int

func (*BlockchainParametersMock) GetMinimumClientVersion

func (bp *BlockchainParametersMock) GetMinimumClientVersion() (*big.Int, *big.Int, *big.Int)

func (*BlockchainParametersMock) GetUptimeLookbackWindow

func (bp *BlockchainParametersMock) GetUptimeLookbackWindow() *big.Int

func (*BlockchainParametersMock) IntrinsicGasForAlternativeFeeCurrency

func (bp *BlockchainParametersMock) IntrinsicGasForAlternativeFeeCurrency() *big.Int

type CeloMock

type CeloMock struct {
	Runner               *MockEVMRunner
	Registry             *RegistryMock
	BlockchainParameters *BlockchainParametersMock
}

func NewCeloMock

func NewCeloMock() CeloMock

type Contract

type Contract interface {
	Call(input []byte) (ret []byte, err error)
}

type ContractMock

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

func NewContractMock

func NewContractMock(parsedAbi *abi.ABI, handler interface{}) ContractMock

func NewSingleMethodContract

func NewSingleMethodContract(registryId common.Hash, methodName string, mockFn interface{}) *ContractMock

func (*ContractMock) Call

func (cm *ContractMock) Call(input []byte) (ret []byte, err error)

type FailingVmRunner

type FailingVmRunner struct{}

FailingVmRunner is a VMRunner that always fails with a ErrFailingRunner

func (FailingVmRunner) Execute

func (fvm FailingVmRunner) Execute(recipient common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, err error)

func (FailingVmRunner) ExecuteFrom

func (fvm FailingVmRunner) ExecuteFrom(sender, recipient common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, err error)

func (FailingVmRunner) GetStateDB

func (fvm FailingVmRunner) GetStateDB() vm.StateDB

func (FailingVmRunner) Query

func (fvm FailingVmRunner) Query(recipient common.Address, input []byte, gas uint64) (ret []byte, err error)

func (FailingVmRunner) StartGasMetering

func (fvm FailingVmRunner) StartGasMetering()

func (FailingVmRunner) StopGasMetering

func (fvm FailingVmRunner) StopGasMetering()

type MethodMock

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

func NewMethod

func NewMethod(m *abi.Method, fnVal reflect.Value) *MethodMock

func (*MethodMock) Call

func (mm *MethodMock) Call(input []byte) (ret []byte, err error)

func (*MethodMock) Id

func (mm *MethodMock) Id() []byte

type MockEVMRunner

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

func NewMockEVMRunner

func NewMockEVMRunner() *MockEVMRunner

func NewSingleMethodRunner

func NewSingleMethodRunner(registryId common.Hash, methodName string, mockFn interface{}) *MockEVMRunner

func (*MockEVMRunner) Execute

func (ev *MockEVMRunner) Execute(recipient common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, err error)

func (*MockEVMRunner) ExecuteFrom

func (ev *MockEVMRunner) ExecuteFrom(sender, recipient common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, err error)

func (*MockEVMRunner) GetStateDB

func (ev *MockEVMRunner) GetStateDB() vm.StateDB

GetStateDB implements Backend.GetStateDB

func (*MockEVMRunner) Query

func (ev *MockEVMRunner) Query(recipient common.Address, input []byte, gas uint64) (ret []byte, err error)

func (*MockEVMRunner) RegisterContract

func (ev *MockEVMRunner) RegisterContract(address common.Address, mock Contract)

func (*MockEVMRunner) StartGasMetering

func (ev *MockEVMRunner) StartGasMetering()

func (*MockEVMRunner) StopGasMetering

func (ev *MockEVMRunner) StopGasMetering()

type RegistryMock

type RegistryMock struct {
	ContractMock
	Contracts map[common.Hash]common.Address
}

func NewRegistryMock

func NewRegistryMock() *RegistryMock

func (*RegistryMock) AddContract

func (rm *RegistryMock) AddContract(id common.Hash, address common.Address)

func (*RegistryMock) GetAddressFor

func (rm *RegistryMock) GetAddressFor(id common.Hash) common.Address

Jump to

Keyboard shortcuts

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