network

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: 55 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrefundedAccountInitialBalance, _ = sdkmath.NewIntFromString("100_000_000_000_000_000_000_000")

PrefundedAccountInitialBalance is the amount of tokens that each prefunded account has at genesis. It represents a 100k amount expressed in the 18 decimals representation.

Functions

func DefaultInitialBondedAmount

func DefaultInitialBondedAmount() math.Int

func GetInitialAmount

func GetInitialAmount(decimals evmtypes.Decimals) math.Int

func GetInitialBaseFeeAmount

func GetInitialBaseFeeAmount(decimals evmtypes.Decimals) math.LegacyDec

func GetInitialBondedAmount

func GetInitialBondedAmount(decimals evmtypes.Decimals) math.Int

func GetWEVMOSContractHex

func GetWEVMOSContractHex(chainID string) string

GetWEVMOSContractHex returns the hex format of address for the WEVMOS contract given the chainID. If the chainID is not found, it defaults to the mainnet address.

Types

type BankCustomGenesisState

type BankCustomGenesisState struct {
	// contains filtered or unexported fields
}

type ChainCoins

type ChainCoins struct {
	// contains filtered or unexported fields
}

ChainCoins information for the coins required from the chian to operate: - baseCoin: represents the base coin used to pay gas fees and staking in the Cosmos context. - evmCoin: represents the evm coin used to pay Ethereum transactions fees.

func DefaultChainCoins

func DefaultChainCoins() ChainCoins

DefaultChainCoins returns the default values used for the ChainCoins in which base and evm denom are the same.

func (ChainCoins) BaseCoin

func (cc ChainCoins) BaseCoin() CoinInfo

func (ChainCoins) BaseDecimals

func (cc ChainCoins) BaseDecimals() evmtypes.Decimals

func (ChainCoins) BaseDenom

func (cc ChainCoins) BaseDenom() string

func (ChainCoins) DenomDecimalsMap

func (cc ChainCoins) DenomDecimalsMap() map[string]evmtypes.Decimals

DenomDecimalsMap returns a map of unique Denom -> Decimals for the chain coins.

func (ChainCoins) EVMCoin

func (cc ChainCoins) EVMCoin() CoinInfo

func (ChainCoins) EVMDecimals

func (cc ChainCoins) EVMDecimals() evmtypes.Decimals

func (ChainCoins) EVMDenom

func (cc ChainCoins) EVMDenom() string

func (ChainCoins) IsBaseEqualToEVM

func (cc ChainCoins) IsBaseEqualToEVM() bool

type CoinInfo

type CoinInfo struct {
	Denom    string
	Decimals evmtypes.Decimals
}

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config defines the configuration for a chain. It allows for customization of the network to adjust to testing needs.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration for a chain.

type ConfigOption

type ConfigOption func(*Config)

ConfigOption defines a function that can modify the NetworkConfig. The purpose of this is to force to be declarative when the default configuration requires to be changed.

func WithAmountOfValidators

func WithAmountOfValidators(amount int) ConfigOption

WithAmountOfValidators sets the amount of validators for the network.

func WithBalances

func WithBalances(balances ...banktypes.Balance) ConfigOption

WithBalances sets the specific balances for the pre-funded accounts, that are being set up for the network.

func WithBaseCoin

func WithBaseCoin(denom string, decimals uint8) ConfigOption

WithBaseCoin sets the denom and decimals for the base coin in the network.

func WithChainID

func WithChainID(chainID string) ConfigOption

WithChainID sets a custom chainID for the network. Changing the chainID change automatically also the EVM coin used. It panics if the chainID is invalid.

func WithCustomBaseAppOpts

func WithCustomBaseAppOpts(opts ...func(*baseapp.BaseApp)) ConfigOption

WithCustomBaseAppOpts sets custom base app options for the network.

func WithCustomGenesis

func WithCustomGenesis(customGenesis CustomGenesisState) ConfigOption

WithCustomGenesis sets the custom genesis of the network for specific modules.

func WithEVMCoin

func WithEVMCoin(_ string, _ uint8) ConfigOption

WithEVMCoin sets the denom and decimals for the evm coin in the network.

func WithOtherDenoms

func WithOtherDenoms(otherDenoms []string) ConfigOption

WithOtherDenoms sets other possible coin denominations for the network.

func WithPreFundedAccounts

func WithPreFundedAccounts(accounts ...sdktypes.AccAddress) ConfigOption

WithPreFundedAccounts sets the pre-funded accounts for the network.

func WithValidatorOperators

func WithValidatorOperators(keys []sdktypes.AccAddress) ConfigOption

WithValidatorOperators overwrites the used operator address for the network instantiation.

type CustomGenesisState

type CustomGenesisState map[string]interface{}

type FeeMarketCustomGenesisState

type FeeMarketCustomGenesisState struct {
	// contains filtered or unexported fields
}

FeeMarketCustomGenesisState defines the fee market genesis state

type GovCustomGenesisState

type GovCustomGenesisState struct {
	// contains filtered or unexported fields
}

GovCustomGenesisState defines the gov genesis state

type InitialAmounts

type InitialAmounts struct {
	Base math.Int
	Evm  math.Int
}

func DefaultInitialAmounts

func DefaultInitialAmounts() InitialAmounts

type IntegrationNetwork

type IntegrationNetwork struct {
	// contains filtered or unexported fields
}

IntegrationNetwork is the implementation of the Network interface for integration tests.

func New

func New(opts ...ConfigOption) *IntegrationNetwork

New configures and initializes a new integration Network instance with the given configuration options. If no configuration options are provided it uses the default configuration.

It panics if an error occurs.

func (*IntegrationNetwork) BroadcastTxSync

func (n *IntegrationNetwork) BroadcastTxSync(txBytes []byte) (abcitypes.ExecTxResult, error)

BroadcastTxSync broadcasts the given txBytes to the network and returns the response. TODO - this should be change to gRPC

func (*IntegrationNetwork) CheckTx

func (n *IntegrationNetwork) CheckTx(txBytes []byte) (*abcitypes.ResponseCheckTx, error)

CheckTx calls the BaseApp's CheckTx method with the given txBytes to the network and returns the response.

func (*IntegrationNetwork) GetAuthClient

func (n *IntegrationNetwork) GetAuthClient() authtypes.QueryClient

func (*IntegrationNetwork) GetAuthzClient

func (n *IntegrationNetwork) GetAuthzClient() authz.QueryClient

func (*IntegrationNetwork) GetBankClient

func (n *IntegrationNetwork) GetBankClient() banktypes.QueryClient

func (*IntegrationNetwork) GetBaseDenom

func (n *IntegrationNetwork) GetBaseDenom() string

GetBaseDenom returns the network's base denom

func (*IntegrationNetwork) GetChainID

func (n *IntegrationNetwork) GetChainID() string

GetChainID returns the network's chainID

func (*IntegrationNetwork) GetContext

func (n *IntegrationNetwork) GetContext() sdktypes.Context

GetContext returns the network's context

func (*IntegrationNetwork) GetDistrClient

func (n *IntegrationNetwork) GetDistrClient() distrtypes.QueryClient

func (*IntegrationNetwork) GetEIP155ChainID

func (n *IntegrationNetwork) GetEIP155ChainID() *big.Int

GetEIP155ChainID returns the network EIP-155 chainID number

func (*IntegrationNetwork) GetERC20Client

func (n *IntegrationNetwork) GetERC20Client() erc20types.QueryClient

func (*IntegrationNetwork) GetEVMChainConfig

func (n *IntegrationNetwork) GetEVMChainConfig() *gethparams.ChainConfig

GetEVMChainConfig returns the network's EVM chain config

func (*IntegrationNetwork) GetEVMDenom

func (n *IntegrationNetwork) GetEVMDenom() string

GetEVMDenom returns the network's evm denom

func (*IntegrationNetwork) GetEncodingConfig

func (n *IntegrationNetwork) GetEncodingConfig() sdktestutil.TestEncodingConfig

GetEncodingConfig returns the network's encoding configuration

func (*IntegrationNetwork) GetEvmClient

func (n *IntegrationNetwork) GetEvmClient() evmtypes.QueryClient

func (*IntegrationNetwork) GetFeeMarketClient

func (n *IntegrationNetwork) GetFeeMarketClient() feemarkettypes.QueryClient

func (*IntegrationNetwork) GetGovClient

func (n *IntegrationNetwork) GetGovClient() govtypes.QueryClient

func (*IntegrationNetwork) GetIBCChain

GetIBCChain returns a TestChain instance for the given network. Note: the sender accounts are not populated. Do not use this accounts to send transactions during tests. The keyring should be used instead.

func (*IntegrationNetwork) GetMintClient

func (n *IntegrationNetwork) GetMintClient() minttypes.QueryClient

func (*IntegrationNetwork) GetOtherDenoms

func (n *IntegrationNetwork) GetOtherDenoms() []string

GetOtherDenoms returns network's other supported denoms

func (*IntegrationNetwork) GetStakingClient

func (n *IntegrationNetwork) GetStakingClient() stakingtypes.QueryClient

func (*IntegrationNetwork) GetValidators

func (n *IntegrationNetwork) GetValidators() []stakingtypes.Validator

GetValidators returns the network's validators

func (*IntegrationNetwork) NextBlock

func (n *IntegrationNetwork) NextBlock() error

NextBlock is a private helper function that runs the EndBlocker logic, commits the changes, updates the header and runs the BeginBlocker

func (*IntegrationNetwork) NextBlockAfter

func (n *IntegrationNetwork) NextBlockAfter(duration time.Duration) error

NextBlockAfter is a private helper function that runs the FinalizeBlock logic, updates the context and commits the changes to have a block time after the given duration.

func (*IntegrationNetwork) NextBlockWithTxs

func (n *IntegrationNetwork) NextBlockWithTxs(txBytes ...[]byte) (*abcitypes.ResponseFinalizeBlock, error)

NextBlockWithTxs is a helper function that runs the FinalizeBlock logic with the provided tx bytes, updates the context and commits the changes to have a block time after the given duration.

func (*IntegrationNetwork) Simulate

func (n *IntegrationNetwork) Simulate(txBytes []byte) (*txtypes.SimulateResponse, error)

Simulate simulates the given txBytes to the network and returns the simulated response. TODO - this should be change to gRPC

func (*IntegrationNetwork) WithIsCheckTxCtx

func (n *IntegrationNetwork) WithIsCheckTxCtx(isCheckTx bool) sdktypes.Context

WithIsCheckTxCtx switches the network's checkTx property

type MintCustomGenesisState

type MintCustomGenesisState struct {
	// contains filtered or unexported fields
}

MintCustomGenesisState defines the gov genesis state

type Network

type Network interface {
	commonnetwork.Network

	GetEIP155ChainID() *big.Int
	GetEVMChainConfig() *gethparams.ChainConfig

	// Clients
	GetERC20Client() erc20types.QueryClient
	GetEvmClient() evmtypes.QueryClient
	GetGovClient() govtypes.QueryClient
	GetFeeMarketClient() feemarkettypes.QueryClient
	GetMintClient() minttypes.QueryClient
}

Network is the interface that wraps the methods to interact with integration test network.

It was designed to avoid users to access module's keepers directly and force integration tests to be closer to the real user's behavior.

type SlashingCustomGenesisState

type SlashingCustomGenesisState struct {
	// contains filtered or unexported fields
}

SlashingCustomGenesisState defines the corresponding validators signing info and missed blocks for the genesis state

type StakingCustomGenesisState

type StakingCustomGenesisState struct {
	// contains filtered or unexported fields
}

StakingCustomGenesisState defines the staking genesis state

type UnitTestNetwork

type UnitTestNetwork struct {
	IntegrationNetwork
	App *exampleapp.ExampleChain
}

UnitTestNetwork is the implementation of the Network interface for unit tests. It embeds the IntegrationNetwork struct to reuse its methods and makes the App public for easier testing.

func NewUnitTestNetwork

func NewUnitTestNetwork(opts ...ConfigOption) *UnitTestNetwork

NewUnitTestNetwork configures and initializes a new Cosmos EVM Network instance with the given configuration options. If no configuration options are provided it uses the default configuration.

It panics if an error occurs. Note: Only uses for Unit Tests

func (*UnitTestNetwork) FundAccount

func (n *UnitTestNetwork) FundAccount(addr sdktypes.AccAddress, coins sdktypes.Coins) error

FundAccount funds the given account with the given amount of coins.

func (*UnitTestNetwork) GetStateDB

func (n *UnitTestNetwork) GetStateDB() *statedb.StateDB

GetStateDB returns the state database for the current block.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳