testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 Cosmos EVM 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 anteinterfaces.EVMKeeper) *statedb.StateDB

NewStateDB returns a new StateDB for testing purposes.

func NoOpNextFn

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

NoOpNextFn 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, NoOpNextFn)`

func PrepareAccountsForDelegationRewards

func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app *app.ExampleChain, addr sdk.AccAddress, balance math.Int, rewards ...math.Int) (sdk.Context, error)

PrepareAccountsForDelegationRewards prepares the test suite for testing to withdraw delegation rewards.

Balance is the amount of tokens that will be left in the account after the setup is done. For each defined reward, a validator is created and tokens are allocated to it using the distribution keeper, such that the given amount of tokens is outstanding as a staking reward for the account.

The setup is done in the following way:

  • Fund the account with the given address with the given balance.
  • If the given balance is zero, the account will be created with zero balance.

For every reward defined in the rewards argument, the following steps are executed:

  • Set up a validator with zero commission and delegate to it -> the account delegation will be 50% of the total delegation.
  • Allocate rewards to the validator.

The function returns the updated context along with a potential error.

Types

This section is empty.

Directories

Path Synopsis
integration
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
JackTT - Gopher 🇻🇳