testutil

package
v0.0.0-...-eccf466 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAuthorizationEvents

func CheckAuthorizationEvents(event abi.Event, precompileAddr, granter, grantee common.Address, res abci.ResponseDeliverTx, height int64, msgTypes []string, amount *big.Int)

CheckAuthorizationEvents is a helper function used in the integration tests and checks if the approval event is emitted.

If the amount is nil, it will not check for the amount in the event, which should be used for any generic approvals.

func CheckEthereumTxFailed

func CheckEthereumTxFailed(ethRes *evmtypes.MsgEthereumTxResponse) (string, bool)

CheckEthereumTxFailed checks if there is a VM error in the transaction response and returns the reason.

func CheckLogs

func CheckLogs(logArgs LogCheckArgs) error

CheckLogs checks the logs for the given events and whether the transaction was successful or not.

func CheckVMError

func CheckVMError(res abci.ResponseDeliverTx, expErrMsg string, args ...interface{}) error

CheckVMError is a helper function used to check if the transaction is reverted with the expected error message in the VmError field of the MsgEthereumResponse struct.

func CreateValidator

func CreateValidator(ctx sdk.Context, t *testing.T, pubKey cryptotypes.PubKey, sk stakingkeeper.Keeper, stakeAmt math.Int)

CreateValidator creates a validator with the given amount of staked tokens in the bond denomination set in the staking keeper.

func NewPrecompileContract

func NewPrecompileContract(t *testing.T, ctx sdk.Context, caller common.Address, precompile vm.ContractRef, gas uint64) (*vm.Contract, sdk.Context)

NewPrecompileContract creates a new precompile contract and sets the gas meter.

Types

type LogCheckArgs

type LogCheckArgs struct {
	// ABIEvents is a map of available abi.Event corresponding to the corresponding event names,
	// which are available in the contract ABI.
	ABIEvents map[string]abi.Event
	// ErrContains is the error message that is expected to be contained in the transaction response.
	ErrContains string
	// ExpEvents are the events which are expected to be emitted.
	ExpEvents []string
	// ExpPass is whether the transaction is expected to pass or not.
	ExpPass bool
	// Res is the response of the transaction.
	//
	// NOTE: This does not have to be set when using contracts.CallContractAndCheckLogs.
	Res abci.ResponseDeliverTx
}

LogCheckArgs is a struct that contains configuration for the log checking.

func (LogCheckArgs) WithABIEvents

func (l LogCheckArgs) WithABIEvents(abiEvents map[string]abi.Event) LogCheckArgs

WithABIEvents sets the ABIEvents field of LogCheckArgs.

func (LogCheckArgs) WithErrContains

func (l LogCheckArgs) WithErrContains(errContains string, printArgs ...interface{}) LogCheckArgs

WithErrContains sets the ErrContains field of LogCheckArgs. If any printArgs are provided, they are used to format the error message.

func (LogCheckArgs) WithExpEvents

func (l LogCheckArgs) WithExpEvents(expEvents ...string) LogCheckArgs

WithExpEvents sets the ExpEvents field of LogCheckArgs.

func (LogCheckArgs) WithExpPass

func (l LogCheckArgs) WithExpPass(expPass bool) LogCheckArgs

WithExpPass sets the ExpPass field of LogCheckArgs.

func (LogCheckArgs) WithRes

WithRes sets the Res field of LogCheckArgs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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