testutil

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: LGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadcastTxBytes

func BroadcastTxBytes(ctx sdk.Context, chainApp *chainapp.EverLast, txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.Context, abci.ExecTxResult, error)

BroadcastTxBytes encodes a transaction and calls DeliverTx on the app. This function returns sdk.Context because it called Finalize block, so changes to Commit Multistore must be reflected to the new context.

func CheckEthTx

func CheckEthTx(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	priv cryptotypes.PrivKey,
	msg sdk.Msg,
) (abci.ResponseCheckTx, error)

CheckEthTx checks a Ethereum tx for a given set of msgs

func CheckEthTxResponse

func CheckEthTxResponse(r abci.ExecTxResult, cdc codec.Codec) (*evm.MsgEthereumTxResponse, error)

CheckEthTxResponse checks that the transaction was executed successfully

func CheckTx

func CheckTx(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	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, chainApp *chainapp.EverLast, 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

  1. FinalizeBlock, which contains: 1.1. preBlock 1.1. beginBlock 1.2. deliverTx 1.3. endBlock
  2. Commit

func Delegate

func Delegate(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	priv *ethsecp256k1.PrivKey,
	delegateAmount sdk.Coin,
	validator stakingtypes.Validator,
) (sdk.Context, abci.ExecTxResult, error)

Delegate delivers a delegate tx

func DeliverEthTx

func DeliverEthTx(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	priv cryptotypes.PrivKey,
	msg sdk.Msg,
) (sdk.Context, 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,
	chainApp *chainapp.EverLast,
	priv cryptotypes.PrivKey,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (sdk.Context, abci.ExecTxResult, error)

DeliverTx delivers a cosmos tx for a given set of msgs

func DeployContract

func DeployContract(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	priv cryptotypes.PrivKey,
	queryClientEvm evm.QueryClient,
	contract evm.CompiledContract,
	constructorArgs ...interface{},
) (sdk.Context, common.Address, error)

DeployContract deploys a contract with the provided private key, compiled contract data and constructor arguments

func DeployContractWithFactory

func DeployContractWithFactory(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	priv cryptotypes.PrivKey,
	factoryAddress common.Address,
) (sdk.Context, common.Address, abci.ExecTxResult, error)

DeployContractWithFactory deploys a contract using a contract factory with the provided factoryAddress

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 native coin 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 CometBFT header 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 ReflectChangesToCommitMultiStore

func ReflectChangesToCommitMultiStore(ctx sdk.Context, baseApp *baseapp.BaseApp) sdk.Context

ReflectChangesToCommitMultiStore commit the current state directly into the base app's commit multistore. Since Cosmos-SDK v0.50, the block execution context is maintained internally, that make Commit can not pass context to finalize.

func SubmitProposal

func SubmitProposal(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	pk *ethsecp256k1.PrivKey,
	content govv1beta1.Content,
	eventNum int,
) (updatedCtx sdk.Context, 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 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.

func Vote

func Vote(
	ctx sdk.Context,
	chainApp *chainapp.EverLast,
	priv *ethsecp256k1.PrivKey,
	proposalID uint64,
	voteOption govv1beta1.VoteOption,
) (sdk.Context, abci.ExecTxResult, error)

Vote delivers a vote tx with the VoteOption "yes"

Types

This section is empty.

Directories

Path Synopsis
Package network implements and exposes a fully operational in-process CometBFT test network that consists of at least one or potentially many validators.
Package network implements and exposes a fully operational in-process CometBFT 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