suite

package
v0.0.0-...-264aa70 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxTypeEVM    = "EVMTx"
	TxTypeCosmos = "CosmosTx"

	NodeArgsChainID                    = "--chain-id=local-4221"
	NodeArgsEVMChainID                 = "--evm.evm-chain-id=4221"
	NodeArgsApiEnable                  = "--api.enable=true"
	NodeArgsJsonrpcApi                 = "--json-rpc.api=eth,txpool,personal,net,debug,web3"
	NodeArgsJsonrpcAllowUnprotectedTxs = "--json-rpc.allow-unprotected-txs=true"
	NodeArgsMinimumGasPrice            = "--minimum-gas-prices=0.000001atest"
	NodeArgsMaxTxs                     = "--mempool.max-txs=0"

	NodeArgPendingTxProposalTimeout = "--evm.mempool.pending-tx-proposal-timeout=200ms"
	NodeArgInsertQueueSize          = "--evm.mempool.insert-queue-size=1000"
)
View Source
const DefaultGasPriceMultiplier int64 = 10

Variables

This section is empty.

Functions

func DefaultNodeArgs

func DefaultNodeArgs() []string

DefaultNodeArgs returns the default node arguments for starting the chain.

func MempoolArgs

func MempoolArgs() []string

MempoolArgs returns the node arguments to run with the mempool.

func MempoolMinGasPriceZeroArgs

func MempoolMinGasPriceZeroArgs() []string

MempoolMinGasPriceZeroArgs returns the node arguments to run with the mempool with no min gas price.

func MinimumGasPriceZeroArgs

func MinimumGasPriceZeroArgs() []string

MinimumGasPriceZeroArgs returns the node arguments with minimum gas price set to zero.

func RunWithSharedSuite

func RunWithSharedSuite(t *testing.T, fn func(*testing.T, *BaseTestSuite), nodeStartArgs ...string)

RunWithSharedSuite retrieves the shared suite instance and executes the provided test function.

Types

type BaseTestSuite

type BaseTestSuite struct {
	*systemtests.SystemUnderTest

	// Clients
	EthClient    *clients.EthClient
	CosmosClient *clients.CosmosClient
	// contains filtered or unexported fields
}

BaseTestSuite implements the TestSuite interface and provides methods for managing test lifecycle, sending transactions, querying state, and managing expected mempool state.

func GetSharedSuite

func GetSharedSuite(t *testing.T) *BaseTestSuite

func NewBaseTestSuite

func NewBaseTestSuite(t *testing.T) *BaseTestSuite

func (*BaseTestSuite) Acc

func (s *BaseTestSuite) Acc(idx int) *TestAccount

Acc returns the test account for the given index

func (*BaseTestSuite) AccID

func (s *BaseTestSuite) AccID(idx int) string

AccID returns the identifier of the test account for the given index.

func (*BaseTestSuite) Account

func (s *BaseTestSuite) Account(id string) *TestAccount

Account returns the shared test account matching the identifier.

func (*BaseTestSuite) BaseFee

func (s *BaseTestSuite) BaseFee() *big.Int

BaseFee returns the most recently retrieved and stored baseFee.

func (*BaseTestSuite) BaseFeeMultiplier

func (s *BaseTestSuite) BaseFeeMultiplier(multiplier int64) *big.Int

BaseFeeMultiplier returns the cached base fee scaled by the provided multiplier.

func (*BaseTestSuite) CheckTxPending

func (s *BaseTestSuite) CheckTxPending(
	nodeID string,
	txHash string,
	txType string,
	timeout time.Duration,
) error

CheckTxPending checks if the given tx is pending within the timeout duration

func (*BaseTestSuite) CheckTxsPendingAsync

func (s *BaseTestSuite) CheckTxsPendingAsync(expPendingTxs []*TxInfo) error

CheckTxsPendingAsync verifies that the expected pending transactions are still pending in the mempool. The check runs asynchronously because, if done synchronously, the pending transactions might be committed before the verification takes place.

func (*BaseTestSuite) CheckTxsQueuedAsync

func (s *BaseTestSuite) CheckTxsQueuedAsync(expQueuedTxs []*TxInfo) error

CheckTxsQueuedAsync verifies asynchronously that the expected queued transactions are actually queued (and not pending) in the mempool. It mirrors CheckTxsPendingAsync in style to better surface API failures when querying txpool content.

func (*BaseTestSuite) CosmosAccount

func (s *BaseTestSuite) CosmosAccount(id string) *clients.CosmosAccount

CosmosAccount returns the Cosmos account associated with the given identifier.

func (*BaseTestSuite) EthAccount

func (s *BaseTestSuite) EthAccount(id string) *clients.EthAccount

EthAccount returns the Ethereum account associated with the given identifier.

func (*BaseTestSuite) GasPrice

func (s *BaseTestSuite) GasPrice() *big.Int

GasPrice returns the gas price computed from the cached base fee using the default multiplier.

func (*BaseTestSuite) GasPriceMultiplier

func (s *BaseTestSuite) GasPriceMultiplier(multiplier int64) *big.Int

GasPriceMultiplier returns the gas price computed from the cached base fee scaled by the provided multiplier.

func (*BaseTestSuite) GetLatestBaseFee

func (s *BaseTestSuite) GetLatestBaseFee(nodeID string) (*big.Int, error)

GetLatestBaseFee returns the base fee of the latest block

func (*BaseTestSuite) GetOptions

func (s *BaseTestSuite) GetOptions() *TestOptions

GetOptions returns the current test options

func (*BaseTestSuite) LockChain

func (s *BaseTestSuite) LockChain()

LockChain acquires exclusive control over the underlying chain lifecycle.

func (*BaseTestSuite) ModifyCometMempool

func (s *BaseTestSuite) ModifyCometMempool(t *testing.T, mempoolType string)

ModifyCometMempool modifies the mempool type in the config.toml

func (*BaseTestSuite) ModifyConsensusTimeout

func (s *BaseTestSuite) ModifyConsensusTimeout(t *testing.T, timeout string)

ModifyConsensusTimeout modifies the consensus timeout_commit in the config.toml for all nodes and restarts the chain with the new configuration.

func (*BaseTestSuite) Node

func (s *BaseTestSuite) Node(idx int) string

Node returns the node ID for the given index

func (*BaseTestSuite) Nodes

func (s *BaseTestSuite) Nodes() []string

Nodes returns the node IDs in the system under test

func (*BaseTestSuite) NonceAt

func (s *BaseTestSuite) NonceAt(nodeID string, accID string) (uint64, error)

NonceAt returns the account nonce for the given account at the latest block

func (*BaseTestSuite) SendCosmosTx

func (s *BaseTestSuite) SendCosmosTx(
	t *testing.T,
	nodeID string,
	accID string,
	nonceIdx uint64,
	gasPrice *big.Int,
	gasTipCap *big.Int,
) (*TxInfo, error)

SendCosmosTx sends a Cosmos transaction.

func (*BaseTestSuite) SendEthDynamicFeeTx

func (s *BaseTestSuite) SendEthDynamicFeeTx(
	t *testing.T,
	nodeID string,
	accID string,
	nonceIdx uint64,
	gasFeeCap *big.Int,
	gasTipCap *big.Int,
) (*TxInfo, error)

SendEthDynamicFeeTx sends an Ethereum dynamic fee transaction.

func (*BaseTestSuite) SendEthLegacyTx

func (s *BaseTestSuite) SendEthLegacyTx(
	t *testing.T,
	nodeID string,
	accID string,
	nonceIdx uint64,
	gasPrice *big.Int,
) (*TxInfo, error)

SendEthLegacyTx sends an Ethereum legacy transaction.

func (*BaseTestSuite) SendEthTx

func (s *BaseTestSuite) SendEthTx(
	t *testing.T,
	nodeID string,
	accID string,
	nonceIdx uint64,
	gasPrice *big.Int,
	gasTipCap *big.Int,
) (*TxInfo, error)

SendEthTx sends an Ethereum transaction (either Legacy or Dynamic Fee based on options).

func (*BaseTestSuite) SendTx

func (s *BaseTestSuite) SendTx(
	t *testing.T,
	nodeID string,
	accID string,
	nonceIdx uint64,
	gasPrice *big.Int,
	gasTipCap *big.Int,
) (*TxInfo, error)

GetOptions retrieves the current test options.

func (*BaseTestSuite) SetBaseFee

func (s *BaseTestSuite) SetBaseFee(fee *big.Int)

SetBaseFee overrides the cached base fee.

func (*BaseTestSuite) SetNodeStartArgs

func (suite *BaseTestSuite) SetNodeStartArgs(nodeStartArgs ...string)

func (*BaseTestSuite) SetOptions

func (s *BaseTestSuite) SetOptions(options *TestOptions)

SetOptions sets the current test options

func (*BaseTestSuite) SetupTest

func (s *BaseTestSuite) SetupTest(t *testing.T, opts ...TestSetupConfigOption)

SetupTest initializes the test suite by resetting and starting the chain, then awaiting 2 blocks

func (*BaseTestSuite) TxPoolContent

func (s *BaseTestSuite) TxPoolContent(nodeID string, txType string, timeout time.Duration) (pendingTxs, queuedTxs []string, err error)

TxPoolContent returns the pending and queued tx hashes in the tx pool of the given node

func (*BaseTestSuite) UnlockChain

func (s *BaseTestSuite) UnlockChain()

UnlockChain releases the chain lifecycle lock.

func (*BaseTestSuite) WaitForCommit

func (s *BaseTestSuite) WaitForCommit(
	nodeID string,
	txHash string,
	txType string,
	timeout time.Duration,
) error

BaseFee returns the base fee of the latest block

type TestAccount

type TestAccount struct {
	ID         string
	Address    common.Address
	AccAddress sdk.AccAddress
	AccNumber  uint64

	ECDSAPrivKey *ecdsa.PrivateKey
	PrivKey      *ethsecp256k1.PrivKey

	Eth    *clients.EthAccount
	Cosmos *clients.CosmosAccount
}

TestAccount aggregates account metadata usable across both Ethereum and Cosmos flows.

type TestOptions

type TestOptions struct {
	Description    string
	TxType         string
	IsDynamicFeeTx bool
}

TestOptions defines the options for a test case.

type TestSetupConfig

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

func (TestSetupConfig) Equals

func (tc TestSetupConfig) Equals(other TestSetupConfig) bool

type TestSetupConfigOption

type TestSetupConfigOption func(*TestSetupConfig)

func WithTimeoutCommit

func WithTimeoutCommit(tc time.Duration) TestSetupConfigOption

type TxInfo

type TxInfo struct {
	DstNodeID string
	TxType    string
	TxHash    string
}

TxInfo holds information about a transaction.

func NewTxInfo

func NewTxInfo(nodeID, txHash, txType string) *TxInfo

NewTxInfo creates a new TxInfo instance.

Jump to

Keyboard shortcuts

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