network

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// PrefundedAccountInitialBalance is the amount of tokens that each prefunded account has at genesis
	PrefundedAccountInitialBalance = sdktypes.NewInt(int64(math.Pow10(18) * 4))
)

Functions

This section is empty.

Types

type BankCustomGenesisState

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

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 WithChainID

func WithChainID(chainID string) ConfigOption

WithChainID sets a custom chainID for the network. It panics if the chainID is invalid.

func WithDenom

func WithDenom(denom string) ConfigOption

WithDenom sets the denom for the network.

func WithPreFundedAccounts

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

WithPreFundedAccounts sets the pre-funded accounts for the network.

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.ResponseDeliverTx, error)

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

func (*IntegrationNetwork) FundAccount

func (n *IntegrationNetwork) FundAccount(addr sdk.AccAddress, coins sdk.Coins) error

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

func (*IntegrationNetwork) FundAccountWithBaseDenom

func (n *IntegrationNetwork) FundAccountWithBaseDenom(addr sdk.AccAddress, amount sdkmath.Int) error

FundAccountWithBaseDenom funds the given account with the given amount of the network's base denomination.

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) GetChainID

func (n *IntegrationNetwork) GetChainID() string

GetChainID returns the network's chainID

func (*IntegrationNetwork) GetCoinomicsClient

func (n *IntegrationNetwork) GetCoinomicsClient() coinomicstypes.QueryClient

func (*IntegrationNetwork) GetContext

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

GetContext returns the network's context

func (*IntegrationNetwork) GetDenom

func (n *IntegrationNetwork) GetDenom() string

GetDenom returns the network's denom

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) 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) 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 EndBlocker logic, commits the changes, updates the header to have a block time after the given duration and runs the BeginBlocker.

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) UpdateCoinomicsParams

func (n *IntegrationNetwork) UpdateCoinomicsParams(params coinomicstypes.Params) error

func (*IntegrationNetwork) UpdateEvmParams

func (n *IntegrationNetwork) UpdateEvmParams(params evmtypes.Params) error

func (*IntegrationNetwork) UpdateGovParams

func (n *IntegrationNetwork) UpdateGovParams(params govtypes.Params) error

type Network

type Network interface {
	commonnetwork.Network

	GetEIP155ChainID() *big.Int

	// Clients
	GetERC20Client() erc20types.QueryClient
	GetEvmClient() evmtypes.QueryClient
	GetGovClient() govtypes.QueryClient
	GetCoinomicsClient() coinomicstypes.QueryClient
	GetFeeMarketClient() feemarkettypes.QueryClient

	// Because to update the module params on a conventional manner governance
	// would be required, we should provide an easier way to update the params
	UpdateEvmParams(params evmtypes.Params) error
	UpdateGovParams(params govtypes.Params) error
	UpdateCoinomicsParams(params coinomicstypes.Params) error
}

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 StakingCustomGenesisState

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

StakingCustomGenesisState defines the staking genesis state

type UnitTestNetwork

type UnitTestNetwork struct {
	IntegrationNetwork
	App *app.Haqq
}

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 Haqq 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) 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