testutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: LGPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Copyright 2021 Evmos Foundation This file is part of Evmos' Ethermint library.

The Ethermint library 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 Ethermint library is 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 Ethermint library. If not, see https://github.com/Helios-Chain-Labs/ethermint/blob/main/LICENSE

Index

Constants

View Source
const (
	// TestnetChainID defines the Evmos EIP155 chain ID for testnet
	TestnetChainID = "ethermint-9000"
	// BaseDenom defines the Evmos mainnet denomination
	BaseDenom = "inj"
)

Variables

View Source
var DefaultConsensusParams = &cmtproto.ConsensusParams{
	Block: &cmtproto.BlockParams{
		MaxBytes: 1048576,
		MaxGas:   81500000,
	},
	Evidence: &cmtproto.EvidenceParams{
		MaxAgeNumBlocks: 302400,
		MaxAgeDuration:  504 * time.Hour,
		MaxBytes:        10000,
	},
	Validator: &cmtproto.ValidatorParams{
		PubKeyTypes: []string{
			tmtypes.ABCIPubKeyTypeEd25519,
		},
	},
}

DefaultConsensusParams defines the default Tendermint consensus params used in EthermintApp testing.

Functions

func Commit

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 FundAccount

func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, 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. This should be used for testing purposes only!

func FundModuleAccount

func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, 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. This should be used for testing purposes only!

func NewTestGenesisState

func NewTestGenesisState(codec codec.Codec, genesisState map[string]json.RawMessage) app.GenesisState

NewTestGenesisState generate genesis state with single validator

func RandomAccounts

func RandomAccounts(r *rand.Rand, n int) []simtypes.Account

RandomAccounts creates random accounts with an ethsecp256k1 private key TODO: replace secp256k1.GenPrivKeyFromSecret() with similar function in go-ethereum

func RandomGenesisAccounts

func RandomGenesisAccounts(simState *module.SimulationState) authtypes.GenesisAccounts

RandomGenesisAccounts is used by the auth module to create random genesis accounts in simulation when a genesis.json is not specified. In contrast, the default auth module's RandomGenesisAccounts implementation creates only base accounts and vestings accounts.

func Setup

func Setup(isCheckTx bool, patch func(*app.EthermintApp, app.GenesisState) app.GenesisState) *app.EthermintApp

Setup initializes a new EthermintApp. A Nop logger is set in EthermintApp.

func SetupWithDB

func SetupWithDB(isCheckTx bool, patch func(*app.EthermintApp, app.GenesisState) app.GenesisState, db dbm.DB) *app.EthermintApp

func SetupWithDBAndOpts

func SetupWithDBAndOpts(
	isCheckTx bool,
	patch func(*app.EthermintApp, app.GenesisState) app.GenesisState,
	db dbm.DB,
	appOptions simtestutil.AppOptionsMap,
) *app.EthermintApp

SetupWithDBAndOpts initializes a new EthermintApp. A Nop logger is set in EthermintApp.

func SetupWithOpts

func SetupWithOpts(
	isCheckTx bool,
	patch func(*app.EthermintApp, app.GenesisState) app.GenesisState,
	appOptions simtestutil.AppOptionsMap,
) *app.EthermintApp

func StateFn

func StateFn(a *app.EthermintApp) simtypes.AppStateFn

StateFn returns the initial application state using a genesis or the simulation parameters. It is a wrapper of simapp.AppStateFn to replace evm param EvmDenom with staking param BondDenom.

Types

type BaseTestSuite

type BaseTestSuite struct {
	suite.Suite

	Ctx sdk.Context
	App *app.EthermintApp
}

func (*BaseTestSuite) MintFeeCollectorVirtual

func (suite *BaseTestSuite) MintFeeCollectorVirtual(coins sdk.Coins)

func (*BaseTestSuite) SetupTest

func (suite *BaseTestSuite) SetupTest()

func (*BaseTestSuite) SetupTestWithCb

func (suite *BaseTestSuite) SetupTestWithCb(
	t require.TestingT,
	patch func(*app.EthermintApp, app.GenesisState) app.GenesisState,
)

func (*BaseTestSuite) SetupTestWithCbAndOpts

func (suite *BaseTestSuite) SetupTestWithCbAndOpts(
	_ require.TestingT,
	patch func(*app.EthermintApp, app.GenesisState) app.GenesisState,
	appOptions simtestutil.AppOptionsMap,
)

func (*BaseTestSuite) StateDB

func (suite *BaseTestSuite) StateDB() *statedb.StateDB

type BaseTestSuiteWithAccount

type BaseTestSuiteWithAccount struct {
	BaseTestSuite
	Address     common.Address
	PrivKey     *ethsecp256k1.PrivKey
	Signer      keyring.Signer
	ConsAddress sdk.ConsAddress
	ConsPubKey  cryptotypes.PubKey
}

func (*BaseTestSuiteWithAccount) BuildEthTx

func (suite *BaseTestSuiteWithAccount) BuildEthTx(
	to *common.Address,
	gasLimit uint64,
	gasPrice *big.Int,
	gasFeeCap *big.Int,
	gasTipCap *big.Int,
	accesses *ethtypes.AccessList,
	privKey *ethsecp256k1.PrivKey,
) *types.MsgEthereumTx

func (*BaseTestSuiteWithAccount) CheckTx

func (suite *BaseTestSuiteWithAccount) CheckTx(tx []byte) abci.ResponseCheckTx

func (*BaseTestSuiteWithAccount) Commit

func (suite *BaseTestSuiteWithAccount) Commit(t require.TestingT)

Commit and begin new block

func (*BaseTestSuiteWithAccount) DeliverTx

func (suite *BaseTestSuiteWithAccount) DeliverTx(tx []byte) *abci.ExecTxResult

func (*BaseTestSuiteWithAccount) PostSetupValidator

func (suite *BaseTestSuiteWithAccount) PostSetupValidator(t require.TestingT) stakingtypes.Validator

func (*BaseTestSuiteWithAccount) PrepareEthTx

func (suite *BaseTestSuiteWithAccount) PrepareEthTx(msgEthereumTx *types.MsgEthereumTx, privKey *ethsecp256k1.PrivKey) []byte

func (*BaseTestSuiteWithAccount) SetupAccount

func (suite *BaseTestSuiteWithAccount) SetupAccount(t require.TestingT)

func (*BaseTestSuiteWithAccount) SetupTest

func (suite *BaseTestSuiteWithAccount) SetupTest(t require.TestingT)

func (*BaseTestSuiteWithAccount) SetupTestWithCb

func (suite *BaseTestSuiteWithAccount) SetupTestWithCb(
	t require.TestingT,
	patch func(*app.EthermintApp, app.GenesisState) app.GenesisState,
)

func (*BaseTestSuiteWithAccount) SetupTestWithCbAndOpts

func (suite *BaseTestSuiteWithAccount) SetupTestWithCbAndOpts(
	t require.TestingT,
	patch func(*app.EthermintApp, app.GenesisState) app.GenesisState,
	appOptions simtestutil.AppOptionsMap,
)

type BaseTestSuiteWithFeeMarketQueryClient

type BaseTestSuiteWithFeeMarketQueryClient struct {
	BaseTestSuite
	// contains filtered or unexported fields
}

func (*BaseTestSuiteWithFeeMarketQueryClient) Setup

func (trait *BaseTestSuiteWithFeeMarketQueryClient) Setup(suite *BaseTestSuite)

func (*BaseTestSuiteWithFeeMarketQueryClient) SetupTest

func (suite *BaseTestSuiteWithFeeMarketQueryClient) SetupTest()

func (*BaseTestSuiteWithFeeMarketQueryClient) SetupTestWithCb

type EVMTestSuiteWithAccountAndQueryClient

type EVMTestSuiteWithAccountAndQueryClient struct {
	BaseTestSuiteWithAccount
	// contains filtered or unexported fields
}

func (*EVMTestSuiteWithAccountAndQueryClient) Commit

Commit and begin new block

func (*EVMTestSuiteWithAccountAndQueryClient) DeployTestContract

func (suite *EVMTestSuiteWithAccountAndQueryClient) DeployTestContract(
	t require.TestingT,
	owner common.Address,
	supply *big.Int,
	enableFeemarket bool,
) common.Address

DeployTestContract deploy a test erc20 contract and returns the contract address

func (*EVMTestSuiteWithAccountAndQueryClient) EvmDenom

func (*EVMTestSuiteWithAccountAndQueryClient) Setup

func (trait *EVMTestSuiteWithAccountAndQueryClient) Setup(suite *BaseTestSuite)

func (*EVMTestSuiteWithAccountAndQueryClient) SetupTest

func (*EVMTestSuiteWithAccountAndQueryClient) SetupTestWithCb

Directories

Path Synopsis
// Copyright 2021 Evmos Foundation // This file is part of Evmos' Ethermint library.
// Copyright 2021 Evmos Foundation // This file is part of Evmos' Ethermint library.

Jump to

Keyboard shortcuts

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