testutil

package
v0.3.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: LGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Copyright 2022 Evmos Foundation This file is part of the Evmos Network packages.

Evmos is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The Evmos packages are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the Evmos packages. If not, see https://github.com/evmos/evmos/blob/main/LICENSE

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTxBytes

func BroadcastTxBytes(
	app *app.Mezo,
	txEncoder sdk.TxEncoder,
	tx sdk.Tx,
	blockHeight int64,
	proposer sdk.ConsAddress,
) (*abci.ExecTxResult, error)

BroadcastTxBytes encodes a transaction and calls DeliverTx on the app.

func CheckEthTx

func CheckEthTx(
	appMezo *app.Mezo,
	priv cryptotypes.PrivKey,
	msgs ...sdk.Msg,
) (*abci.ResponseCheckTx, error)

CheckEthTx checks a Ethereum tx for a given set of msgs

func CheckTx

func CheckTx(
	ctx sdk.Context,
	appMezo *app.Mezo,
	priv cryptotypes.PrivKey,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (*abci.ResponseCheckTx, error)

CheckTx checks a cosmos tx for a given set of msgs

func Commit

func Commit(ctx sdk.Context, app *app.Mezo, t time.Duration, vs *tmtypes.ValidatorSet) (sdk.Context, error)

Commit commits a block at a given time. Reminder: At the end of each Tendermint Consensus round the following methods are run

  1. BeginBlock
  2. DeliverTx
  3. EndBlock
  4. Commit

func DeliverEthTx

func DeliverEthTx(
	ctx sdk.Context,
	appMezo *app.Mezo,
	proposer sdk.ConsAddress,
	priv cryptotypes.PrivKey,
	msgs ...sdk.Msg,
) (*abci.ExecTxResult, error)

DeliverEthTx generates and broadcasts a Cosmos Tx populated with MsgEthereumTx messages. If a private key is provided, it will attempt to sign all messages with the given private key, otherwise, it will assume the messages have already been signed.

func DeliverTx

func DeliverTx(
	ctx sdk.Context,
	appMezo *app.Mezo,
	priv cryptotypes.PrivKey,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (*abci.ExecTxResult, error)

DeliverTx delivers a cosmos tx for a given set of msgs

func FundAccount

func FundAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amounts sdk.Coins) error

FundAccount is a utility function that funds an account by minting and sending the coins to the address.

func FundAccountWithBaseDenom

func FundAccountWithBaseDenom(ctx sdk.Context, bankKeeper bankkeeper.Keeper, addr sdk.AccAddress, amount int64) error

FundAccountWithBaseDenom is a utility function that uses the FundAccount function to fund an account with the default Mezo denomination.

func FundModuleAccount

func FundModuleAccount(ctx sdk.Context, bankKeeper bankkeeper.Keeper, recipientMod string, amounts sdk.Coins) error

FundModuleAccount is a utility function that funds a module account by minting and sending the coins to the address.

func NewHeader

func NewHeader(
	height int64,
	blockTime time.Time,
	chainID string,
	proposer sdk.ConsAddress,
	appHash,
	validatorHash []byte,
) tmproto.Header

NewHeader creates a new Tendermint header for testing purposes.

func NewStateDB

func NewStateDB(ctx sdk.Context, evmKeeper evm.EVMKeeper) *statedb.StateDB

NewStateDB returns a new StateDB for testing purposes.

func NextFn

func NextFn(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error)

NextFn is a no-op function that returns the context and no error in order to mock the next function in the AnteHandler chain.

It can be used in unit tests when calling a decorator's AnteHandle method, e.g. `dec.AnteHandle(ctx, tx, false, NextFn)`

func PrepareAccount

func PrepareAccount(
	ctx sdk.Context,
	accountKeeper authkeeper.AccountKeeper,
	bankKeeper bankkeeper.Keeper,
	addr sdk.AccAddress,
	balance sdkmath.Int,
) error

PrepareAccount creates an account with the given balance of the base denomination. If the balance is zero, it just creates an account without any funds.

func ValidateAnteForMsgs

func ValidateAnteForMsgs(ctx sdk.Context, dec sdk.AnteDecorator, msgs ...sdk.Msg) error

ValidateAnteForMsgs is a helper function, which takes in an AnteDecorator as well as 1 or more messages, builds a transaction containing these messages, and returns any error that the AnteHandler might return.

Types

This section is empty.

Directories

Path Synopsis
Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.
Package network implements and exposes a fully operational in-process Tendermint test network that consists of at least one or potentially many validators.

Jump to

Keyboard shortcuts

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