testutil

package
v0.0.0-...-0bc9eb3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2025 License: Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EthDefaultConsensusParams = &cmtypes.ConsensusParams{
	Block: cmtypes.BlockParams{
		MaxBytes: 200000,
		MaxGas:   -1,
	},
	Evidence: cmtypes.EvidenceParams{
		MaxAgeNumBlocks: 302400,
		MaxAgeDuration:  504 * time.Hour,
		MaxBytes:        10000,
	},
	Validator: cmtypes.ValidatorParams{
		PubKeyTypes: []string{
			cmtypes.ABCIPubKeyTypeEd25519,
		},
	},
}

EthDefaultConsensusParams defines the default CometBFT consensus params used in Cosmos EVM app testing.

TODO: currently not used

Functions

func BroadcastTxBytes

func BroadcastTxBytes(app evm.EvmApp, txEncoder sdk.TxEncoder, tx sdk.Tx) (abci.ExecTxResult, error)

BroadcastTxBytes encodes a transaction and calls DeliverTx on the app.

func CheckEthTx

func CheckEthTx(
	exampleApp evm.EvmApp,
	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,
	exampleApp evm.EvmApp,
	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 evm.EvmApp, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error)

Commit commits a block at a given time. Reminder: At the end of each CometBFT Consensus round the following methods are run TODO: update with new ABCI++ consideration

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

func CommitAndCreateNewCtx

func CommitAndCreateNewCtx(ctx sdk.Context, app evm.EvmApp, t time.Duration, vs *cmttypes.ValidatorSet) (sdk.Context, error)

CommitAndCreateNewCtx commits a block at a given time creating a ctx with the current settings This is useful to keep test settings that could be affected by EndBlockers, e.g. setting a baseFee == 0 and expecting this condition to continue after commit

func Delegate

func Delegate(
	ctx sdk.Context,
	evmApp evm.EvmApp,
	priv *ethsecp256k1.PrivKey,
	delegateAmount sdk.Coin,
	validator stakingtypes.Validator,
) (abci.ExecTxResult, error)

Delegate delivers a delegate tx

func DeliverEthTx

func DeliverEthTx(
	exampleApp evm.EvmApp,
	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 DeliverEthTxWithoutCheck

func DeliverEthTxWithoutCheck(
	exampleApp evm.EvmApp,
	priv cryptotypes.PrivKey,
	msgs ...sdk.Msg,
) (abci.ExecTxResult, error)

DeliverEthTxWithoutCheck 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. It does not check if the Eth tx is successful or not.

func DeliverTx

func DeliverTx(
	ctx sdk.Context,
	exampleApp evm.EvmApp,
	priv cryptotypes.PrivKey,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (abci.ExecTxResult, error)

DeliverTx delivers a cosmos tx for a given set of msgs

func NewTestGenesisState

func NewTestGenesisState(app evm.EvmApp) testutil.GenesisState

NewTestGenesisState generate genesis state with single validator

It is also setting up the EVM parameters to use sensible defaults.

TODO: are these different genesis functions necessary or can they all be refactored into one? there's also other genesis state functions; some like app.DefaultGenesis() or others in test helpers only.

func SubmitProposal

func SubmitProposal(
	ctx sdk.Context,
	evmApp evm.EvmApp,
	pk *ethsecp256k1.PrivKey,
	content govv1beta1.Content,
	eventNum int,
) (id uint64, err error)

SubmitProposal delivers a submit proposal tx for a given gov content. Depending on the content type, the eventNum needs to specify submit_proposal event.

func Vote

func Vote(
	ctx sdk.Context,
	evmApp evm.EvmApp,
	priv *ethsecp256k1.PrivKey,
	proposalID uint64,
	voteOption govv1beta1.VoteOption,
) (abci.ExecTxResult, error)

Vote delivers a vote tx with the VoteOption "yes"

Types

This section is empty.

Jump to

Keyboard shortcuts

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