integration_test_util

package
v12.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: LGPL-3.0 Imports: 91 Imported by: 0

README

Integration Test Suite utility

was created with aims to:

  • Provide a simple way to set up and run integration tests
  • Able to run integration tests in parallel
  • Environment nearest to E2E testing
  • Initialize a chain with CometBFT node to fully functional testing
  • Init chain with pre-defined set of validators and wallets, easier to trace and debug
  • Able to set up test for Json-RPC server

Notes:

  • To get historical data correctly, need to use query clients/rpc backend/... at corresponding height

Weak points:

  • Only support Linux & MacOS, possible to make it compatible with Windows by enhance the TemporaryHolder functionality
  • Easy to get import circle error, need a dedicated folder for integration test

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IT_VAL_1_ADDR      = "sx1cqetlv987ntelz7s6ntvv95ltrns9qt6yja5x2"
	IT_VAL_1_VAL_ADDR  = "sxvaloper1cqetlv987ntelz7s6ntvv95ltrns9qt6rglj48"
	IT_VAL_1_CONS_ADDR = "sxvalcons1vv3kjxtrh7jredjehk5xw66r62euenss3f4msm"
	IT_VAL_1_MNEMONIC  = "" /* 141-byte string literal not displayed */

	IT_VAL_2_ADDR      = "sx19k6gu9tkr40uyhf86sjmlgy6hu4lpfx45n5v5r"
	IT_VAL_2_VAL_ADDR  = "sxvaloper19k6gu9tkr40uyhf86sjmlgy6hu4lpfx4nfk28w"
	IT_VAL_2_CONS_ADDR = "sxvalcons19fphsrnm2rx9jk4exfdeq46d6ptwlpy35vjze2"
	IT_VAL_2_MNEMONIC  = "" /* 162-byte string literal not displayed */

	IT_VAL_3_ADDR      = "sx1rxczyg2x94dqcn77t4pyhcndg3r889dw73jyz7"
	IT_VAL_3_VAL_ADDR  = "sxvaloper1rxczyg2x94dqcn77t4pyhcndg3r889dwetsz3n"
	IT_VAL_3_CONS_ADDR = "sxvalcons1vxky3ld4llhaqk8nl6pw6xkxqy97rwdaeln6ry"
	IT_VAL_3_MNEMONIC  = "" /* 148-byte string literal not displayed */

	IT_VAL_4_ADDR      = "sx1gmjvfd4pr0yd94t0x8xw4uwg2j0cn9g9vpwqyt"
	IT_VAL_4_VAL_ADDR  = "sxvaloper1gmjvfd4pr0yd94t0x8xw4uwg2j0cn9g9tmvxhx"
	IT_VAL_4_CONS_ADDR = "sxvalcons1yl9a7v952ejxju9fec6hqeuuku4372pnz8x72v"
	IT_VAL_4_MNEMONIC  = "" /* 160-byte string literal not displayed */

	IT_VAL_5_ADDR      = "sx1fpveqajjpt2emsfkr5xwp80074mkn38x9vlju7"
	IT_VAL_5_VAL_ADDR  = "sxvaloper1fpveqajjpt2emsfkr5xwp80074mkn38xzka50n"
	IT_VAL_5_CONS_ADDR = "sxvalcons1p6n7qpnn5lqyyujzrp344drz228l3wx07jr3dj"
	IT_VAL_5_MNEMONIC  = "" /* 149-byte string literal not displayed */
)
View Source
var (
	IT_WAL_1_ADDR     = "sx139mq752delxv78jvtmwxhasyrycufsvr0qhdhe"
	IT_WAL_1_ETH_ADDR = "0x89760f514DCfCCCf1E4c5eDC6Bf6041931c4c183"
	IT_WAL_1_MNEMONIC = "" /* 147-byte string literal not displayed */

	IT_WAL_2_ADDR     = "sx1yxmxrj9zwrkc855zdt2fk83m0r63tcjuhk9wwg"
	IT_WAL_2_ETH_ADDR = "0x21b661c8A270ed83D2826aD49b1E3B78F515E25C"
	IT_WAL_2_MNEMONIC = "" /* 151-byte string literal not displayed */

	IT_WAL_3_ADDR     = "sx1v3uay5np5a93kpv80rfldxkhe32hxsdgukuvqs"
	IT_WAL_3_ETH_ADDR = "0x6479D25261A74B1b058778d3F69Ad7cC557341A8"
	IT_WAL_3_MNEMONIC = "" /* 155-byte string literal not displayed */

	IT_WAL_4_ADDR     = "sx1zsdj9vsw44kk46fmnka7k76smsaxgh6pth7vl8"
	IT_WAL_4_ETH_ADDR = "0x141B22B20ead6d6AE93B9DBBeB7b50DC3A645F41"
	IT_WAL_4_MNEMONIC = "" /* 153-byte string literal not displayed */

	IT_WAL_5_ADDR     = "sx1862crydur2cpjww66dhfzcc26yglvrcsv484rr"
	IT_WAL_5_ETH_ADDR = "0x3E958191BC1AB01939DAD36e91630Ad111F60f10"
	IT_WAL_5_MNEMONIC = "" /* 163-byte string literal not displayed */
)
View Source
var (
	//go:embed compiled_contracts/1-storage.json
	Contract1StorageJson []byte

	// Contract1Storage is the compiled storage contract
	Contract1Storage evmtypes.CompiledContract

	//go:embed compiled_contracts/2-wevmos.json
	Contract2WEvmosJson []byte

	// Contract2WEvmos is the compiled WEVMOS contract
	Contract2WEvmos evmtypes.CompiledContract

	//go:embed compiled_contracts/3-nft721.json
	Contract3Nft721Json []byte

	// Contract3Nft721 is the compiled NFT-721 contract
	Contract3Nft721 evmtypes.CompiledContract

	//go:embed compiled_contracts/4-nft1155.json
	Contract4Nft1155Json []byte

	// Contract4Nft1155 is the compiled NFT-1155 contract
	Contract4Nft1155 evmtypes.CompiledContract

	//go:embed compiled_contracts/5-create-Foo.json
	Contract5CreateFooJson []byte
	//go:embed compiled_contracts/5-create-Bar.json
	Contract5CreateBarJson []byte
	//go:embed compiled_contracts/5-create-BarInteraction.json
	Contract5CreateBarInteractionJson []byte

	// Contract5CreateFooContract is the compiled Foo-contract on 5-create.sol
	Contract5CreateFooContract evmtypes.CompiledContract
	// Contract5CreateBarContract is the compiled Bar-contract on 5-create.sol
	Contract5CreateBarContract evmtypes.CompiledContract
	// Contract5CreateBarInteractionContract is the compiled BarInteraction-contract on 5-create.sol
	Contract5CreateBarInteractionContract evmtypes.CompiledContract
)
View Source
var IntegrationTestChain1 = itutiltypes.ChainConfig{
	CosmosChainId: constants.TestnetFullChainId,
	BaseDenom:     constants.BaseDenom,
	Bech32Prefix:  constants.Bech32Prefix,
	EvmChainId:    constants.TestnetEIP155ChainId,
}
View Source
var IntegrationTestChain2 = itutiltypes.ChainConfig{
	CosmosChainId: "evmos_9000-4",
	BaseDenom:     constants.BaseDenom,
	Bech32Prefix:  "evmos",
	EvmChainId:    9000,
}

Functions

func NewTestAccount

func NewTestAccount(t *testing.T, nilAblePrivKey *ethsecp256k1.PrivKey) *itutiltypes.TestAccount

NewTestAccount creates a new test account. If the private key is not provided, a new one will be generated.

Types

type ChainIntegrationTestSuite

type ChainIntegrationTestSuite struct {
	EncodingConfig       params.EncodingConfig
	ChainConstantsConfig itutiltypes.ChainConstantConfig
	DB                   *itutiltypes.MemDB
	TendermintApp        itutiltypes.TendermintApp
	ChainApp             itutiltypes.ChainApp
	ValidatorSet         *tmtypes.ValidatorSet
	CurrentContext       sdk.Context // might be out-dated if Tendermint is used
	ValidatorAccounts    itutiltypes.TestAccounts
	WalletAccounts       itutiltypes.TestAccounts
	ModuleAccounts       map[string]authtypes.ModuleAccountI
	QueryClients         *itutiltypes.QueryClients
	EvmTxIndexer         *kvindexer.KVIndexer
	RpcBackend           *rpcbackend.Backend
	EthSigner            ethtypes.Signer
	TestConfig           itutiltypes.TestConfig
	// contains filtered or unexported fields
}

ChainIntegrationTestSuite is a helper for Chain integration test.

func CreateChainIntegrationTestSuite

func CreateChainIntegrationTestSuite(t *testing.T, r *require.Assertions) *ChainIntegrationTestSuite

CreateChainIntegrationTestSuite initialize an integration test suite using default configuration.

func CreateChainIntegrationTestSuiteFromChainConfig

func CreateChainIntegrationTestSuiteFromChainConfig(t *testing.T, r *require.Assertions, chainCfg itutiltypes.ChainConfig, disableTendermint bool) *ChainIntegrationTestSuite

CreateChainIntegrationTestSuiteFromChainConfig initialize an integration test suite from a given chain config.

func (*ChainIntegrationTestSuite) BaseApp

func (suite *ChainIntegrationTestSuite) BaseApp() *baseapp.BaseApp

BaseApp returns the BaseApp instance of the Integrated chain.

func (*ChainIntegrationTestSuite) BroadcastTx

func (suite *ChainIntegrationTestSuite) BroadcastTx(tx sdk.Tx) (responseDeliverTx abci.ResponseDeliverTx, err error)

BroadcastTx does broadcast a tx over the network and returns the response The delivery mode is SYNC

func (*ChainIntegrationTestSuite) BroadcastTxAsync

func (suite *ChainIntegrationTestSuite) BroadcastTxAsync(tx sdk.Tx) (resultBroadcastTx *coretypes.ResultBroadcastTx, err error)

BroadcastTxAsync is the same as BroadcastTx but with Async delivery mode.

func (*ChainIntegrationTestSuite) Cleanup

func (suite *ChainIntegrationTestSuite) Cleanup()

Cleanup cleans up the ChainIntegrationTestSuite. This method should be called after each test or suite, depends on the tactic you shut down the Integration chain.

func (*ChainIntegrationTestSuite) Commit

func (suite *ChainIntegrationTestSuite) Commit()

Commit commits and starts a new block with an updated context.

func (*ChainIntegrationTestSuite) ContextAt

func (suite *ChainIntegrationTestSuite) ContextAt(height int64) sdk.Context

ContextAt returns the context at a given context block height.

func (*ChainIntegrationTestSuite) CreateAllQueryClientsAndRpcBackend

func (suite *ChainIntegrationTestSuite) CreateAllQueryClientsAndRpcBackend()

CreateAllQueryClientsAndRpcBackend creates all query clients and RPC backend instance at recent block height. This method should be called after each commit to refresh the query clients.

func (*ChainIntegrationTestSuite) DeliverEthTx

DeliverEthTx generates and broadcasts MsgEthereumTx message populated within a Cosmos tx. The delivery mode is SYNC

func (*ChainIntegrationTestSuite) DeliverEthTxAsync

func (suite *ChainIntegrationTestSuite) DeliverEthTxAsync(
	account *itutiltypes.TestAccount,
	ethMsg *evmtypes.MsgEthereumTx,
) error

DeliverEthTxAsync is the same as DeliverEthTx but with Async delivery mode.

func (*ChainIntegrationTestSuite) DeliverTx

func (suite *ChainIntegrationTestSuite) DeliverTx(
	ctx sdk.Context,
	signer *itutiltypes.TestAccount,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (authsigning.Tx, abci.ResponseDeliverTx, error)

DeliverTx delivers a Cosmos tx for a given set of msgs. The delivery mode is SYNC

func (*ChainIntegrationTestSuite) DeliverTxAsync

func (suite *ChainIntegrationTestSuite) DeliverTxAsync(
	ctx sdk.Context,
	signer *itutiltypes.TestAccount,
	gasPrice *sdkmath.Int,
	msgs ...sdk.Msg,
) (*coretypes.ResultBroadcastTx, error)

DeliverTxAsync is the same as DeliverTx but with Async delivery mode.

func (*ChainIntegrationTestSuite) EnsureTendermint

func (suite *ChainIntegrationTestSuite) EnsureTendermint()

EnsureTendermint trigger test failure immediately if Tendermint is not enabled on integration chain.

func (*ChainIntegrationTestSuite) GetBlockStoreAndStateStore

func (suite *ChainIntegrationTestSuite) GetBlockStoreAndStateStore() (*store.BlockStore, tmstate.Store)

GetBlockStoreAndStateStore returns blockStore and stateStore if Tendermint is Enabled.

WARN: if Tendermint is Disabled, the call will panic.

func (*ChainIntegrationTestSuite) GetIbcTimeoutHeight

func (suite *ChainIntegrationTestSuite) GetIbcTimeoutHeight(offsetHeight int64) ibcclienttypes.Height

GetIbcTimeoutHeight returns a timeout height for IBC packet, based on recent block, plus the offset.

func (*ChainIntegrationTestSuite) GetLatestBlockHeight

func (suite *ChainIntegrationTestSuite) GetLatestBlockHeight() int64

GetLatestBlockHeight returns the most recent block height.

func (*ChainIntegrationTestSuite) GetValidatorAddress

func (suite *ChainIntegrationTestSuite) GetValidatorAddress(number int) sdk.ValAddress

GetValidatorAddress returns the validator address of the validator with the given number. Due to there is a bug that the validator address is delivered from tendermint pubkey instead of cosmos pubkey in tendermint mode. So this function is used to correct the validator address in tendermint mode.

func (*ChainIntegrationTestSuite) HasTendermint

func (suite *ChainIntegrationTestSuite) HasTendermint() bool

HasTendermint indicate if the integration chain has Tendermint enabled.

func (*ChainIntegrationTestSuite) MintCoin

func (suite *ChainIntegrationTestSuite) MintCoin(receiver *itutiltypes.TestAccount, coin sdk.Coin)

MintCoin mints a new amount of coin into given account.

func (*ChainIntegrationTestSuite) MintCoinToCosmosAddress

func (suite *ChainIntegrationTestSuite) MintCoinToCosmosAddress(receiver sdk.AccAddress, coin sdk.Coin)

MintCoinToCosmosAddress mints a new amount of coin into given account.

func (*ChainIntegrationTestSuite) MintCoinToModuleAccount

func (suite *ChainIntegrationTestSuite) MintCoinToModuleAccount(receiver authtypes.ModuleAccountI, coin sdk.Coin)

MintCoinToModuleAccount mints a new amount of coin into given module account.

func (*ChainIntegrationTestSuite) NewBaseCoin

func (suite *ChainIntegrationTestSuite) NewBaseCoin(amount int64) sdk.Coin

NewBaseCoin returns an instance of sdk.Coin of base coin with given amount.

func (*ChainIntegrationTestSuite) PrepareCosmosTx

func (suite *ChainIntegrationTestSuite) PrepareCosmosTx(
	ctx sdk.Context,
	account *itutiltypes.TestAccount,
	args CosmosTxArgs,
) (authsigning.Tx, error)

PrepareCosmosTx creates a cosmos tx and signs it with the provided messages and private key. It returns the signed transaction and an error

func (*ChainIntegrationTestSuite) PrepareEthTx

func (suite *ChainIntegrationTestSuite) PrepareEthTx(
	signer *itutiltypes.TestAccount,
	ethMsg *evmtypes.MsgEthereumTx,
) (authsigning.Tx, error)

PrepareEthTx signs the transaction with the provided MsgEthereumTx.

func (*ChainIntegrationTestSuite) QueryBalance

func (suite *ChainIntegrationTestSuite) QueryBalance(height int64, cosmosAddress string) *sdk.Coin

QueryBalance returns the coin-base balance of given address at given context block. The data is read from query client.

func (*ChainIntegrationTestSuite) QueryBalanceByDenom

func (suite *ChainIntegrationTestSuite) QueryBalanceByDenom(height int64, cosmosAddress, baseDenom string) *sdk.Coin

QueryBalanceByDenom returns the balance of specified denom of given address at given context block. The data is read from query client.

func (*ChainIntegrationTestSuite) QueryBalanceByDenomFromStore

func (suite *ChainIntegrationTestSuite) QueryBalanceByDenomFromStore(height int64, address sdk.AccAddress, baseDenom string) *sdk.Coin

QueryBalanceByDenomFromStore returns the coin-base balance of a specific denom of given address at given context block. The data is read directly from store.

func (*ChainIntegrationTestSuite) QueryBalanceFromStore

func (suite *ChainIntegrationTestSuite) QueryBalanceFromStore(height int64, address sdk.AccAddress) *sdk.Coin

QueryBalanceFromStore returns the coin-base balance of given address at given context block. The data is read directly from store.

func (*ChainIntegrationTestSuite) QueryClientsAt

func (suite *ChainIntegrationTestSuite) QueryClientsAt(height int64) *itutiltypes.QueryClients

QueryClientsAt returns the list of query client instance that connects to store data at a given context block height.

func (*ChainIntegrationTestSuite) QueryDenomHash

func (suite *ChainIntegrationTestSuite) QueryDenomHash(port, channel, denom string) string

QueryDenomHash returns the denom hash of given denom trace information.

func (*ChainIntegrationTestSuite) QueryFirstErc20TokenPair

func (suite *ChainIntegrationTestSuite) QueryFirstErc20TokenPair(sourceErc20 bool) (erc20types.TokenPair, error)

QueryFirstErc20TokenPair returns the first ERC-20 token pair available.

func (*ChainIntegrationTestSuite) QueryGovProposalById

func (suite *ChainIntegrationTestSuite) QueryGovProposalById(id uint64) *govv1types.Proposal

QueryGovProposalById returns the gov proposal of the given proposal id.

func (*ChainIntegrationTestSuite) QueryLatestGovProposal

func (suite *ChainIntegrationTestSuite) QueryLatestGovProposal(proposer *itutiltypes.TestAccount) *govv1types.Proposal

QueryLatestGovProposal returns the latest gov proposal submitted by given proposer.

func (*ChainIntegrationTestSuite) QueryTxResponse

QueryTxResponse returns the TxResponse for the given tx

func (*ChainIntegrationTestSuite) Require

func (suite *ChainIntegrationTestSuite) Require() *require.Assertions

func (*ChainIntegrationTestSuite) RpcBackendAt

func (suite *ChainIntegrationTestSuite) RpcBackendAt(height int64) *rpcbackend.Backend

RpcBackendAt returns the RPC-backend instance at a given context block height.

func (*ChainIntegrationTestSuite) T

func (suite *ChainIntegrationTestSuite) T() *testing.T

func (*ChainIntegrationTestSuite) TxAllVote

func (suite *ChainIntegrationTestSuite) TxAllVote(proposalId uint64, option govv1types.VoteOption)

TxAllVote using all accounts, each submits a vote on given proposal.

func (*ChainIntegrationTestSuite) TxDeploy1StorageContract

TxDeploy1StorageContract deploys the embedded pre-compiled contract "1-storage.sol".

func (*ChainIntegrationTestSuite) TxDeploy2WEvmosContract

TxDeploy2WEvmosContract deploys the embedded pre-compiled contract "2-wevmos.sol".

func (*ChainIntegrationTestSuite) TxDeploy3Nft721Contract

TxDeploy3Nft721Contract deploys the embedded pre-compiled contract "3-nft721.sol".

func (*ChainIntegrationTestSuite) TxDeploy4Nft1155Contract

TxDeploy4Nft1155Contract deploys the embedded pre-compiled contract "4-nft1155.sol".

func (*ChainIntegrationTestSuite) TxDeploy5CreateBarContract

TxDeploy5CreateBarContract deploys the Bar contract within the embedded pre-compiled contract "5-create.sol".

func (*ChainIntegrationTestSuite) TxDeploy5CreateBarInteractionContract

func (suite *ChainIntegrationTestSuite) TxDeploy5CreateBarInteractionContract(deployer *itutiltypes.TestAccount, contractBarAddress common.Address) (common.Address, *evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxDeploy5CreateBarInteractionContract deploys the BarInteraction contract within the embedded pre-compiled contract "5-create.sol".

func (*ChainIntegrationTestSuite) TxDeploy5CreateFooContract

TxDeploy5CreateFooContract deploys the Foo contract within the embedded pre-compiled contract "5-create.sol".

func (*ChainIntegrationTestSuite) TxDeployContract

func (suite *ChainIntegrationTestSuite) TxDeployContract(ctx sdk.Context, deployer *itutiltypes.TestAccount, contract evmtypes.CompiledContract, constructorArgs ...interface{}) (common.Address, *evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxDeployContract deploys the given compiled-contract with the given constructor arguments, using the given deployer.

func (*ChainIntegrationTestSuite) TxDeployErc20Contract

func (suite *ChainIntegrationTestSuite) TxDeployErc20Contract(deployer *itutiltypes.TestAccount, name, symbol string, decimals uint8) (common.Address, *evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxDeployErc20Contract deploys a new ERC20 contract with the given name, symbol and decimals. The given deployer will be used to deploy the contract.

func (*ChainIntegrationTestSuite) TxFullGov

func (suite *ChainIntegrationTestSuite) TxFullGov(proposer *itutiltypes.TestAccount, newProposalContent govtypeslegacy.Content) uint64

TxFullGov submit gov proposal, full vote Yes and wait gov passed.

func (*ChainIntegrationTestSuite) TxFullRegisterCoin

func (suite *ChainIntegrationTestSuite) TxFullRegisterCoin(proposer *itutiltypes.TestAccount, minDenom string) uint64

TxFullRegisterCoin registers a coin with the given denom and amount using Governance module. Auto propose a new proposal, vote and wait till it done.

func (*ChainIntegrationTestSuite) TxFullRegisterCoinByMetadata

func (suite *ChainIntegrationTestSuite) TxFullRegisterCoinByMetadata(proposer *itutiltypes.TestAccount, metadata banktypes.Metadata) uint64

TxFullRegisterCoinByMetadata registers a coin with the given denom metadata using Governance module. Auto propose a new proposal, vote and wait till it done.

func (*ChainIntegrationTestSuite) TxFullRegisterCoinWithNewBankMetadata

func (suite *ChainIntegrationTestSuite) TxFullRegisterCoinWithNewBankMetadata(proposer *itutiltypes.TestAccount, minDenom, display string, exponent uint32) uint64

TxFullRegisterCoinWithNewBankMetadata registers a coin with the given denom metadata using Governance module. Auto propose a new proposal, vote and wait till it done.

func (*ChainIntegrationTestSuite) TxFullRegisterIbcCoinFromErc20Contract

func (suite *ChainIntegrationTestSuite) TxFullRegisterIbcCoinFromErc20Contract(proposer *itutiltypes.TestAccount, erc20Address common.Address) uint64

TxFullRegisterIbcCoinFromErc20Contract registers IBC coin for the given ERC-20 contract address using Governance module. Auto propose a new proposal, vote and wait till it done.

func (*ChainIntegrationTestSuite) TxMintErc20Token

func (suite *ChainIntegrationTestSuite) TxMintErc20Token(contract common.Address, minter, mintTo *itutiltypes.TestAccount, amount uint16, decimals uint8) (*evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxMintErc20Token call the "mint" function of the given ERC-20 contract, minting token to given account. Minter account will be used to call the function.

func (*ChainIntegrationTestSuite) TxPrepareContextWithdrawDelegatorAndValidatorReward

func (suite *ChainIntegrationTestSuite) TxPrepareContextWithdrawDelegatorAndValidatorReward(delegator *itutiltypes.TestAccount, delegate uint8, waitXBlocks uint8) (valAddr sdk.ValAddress)

TxPrepareContextWithdrawDelegatorAndValidatorReward prepares context for withdraw delegator and validator reward. It does create delegation, allocate reward, commit state and wait a few blocks for reward to increase.

func (*ChainIntegrationTestSuite) TxSend

func (suite *ChainIntegrationTestSuite) TxSend(from, to *itutiltypes.TestAccount, amount float64) error

TxSend sends amount of base coin from one to another.

func (*ChainIntegrationTestSuite) TxSendAsync

func (suite *ChainIntegrationTestSuite) TxSendAsync(from, to *itutiltypes.TestAccount, amount float64) error

TxSendAsync is the same as TxSend but with Async delivery mode.

func (*ChainIntegrationTestSuite) TxSendEvmTx

func (suite *ChainIntegrationTestSuite) TxSendEvmTx(ctx sdk.Context, sender *itutiltypes.TestAccount, to *common.Address, amount *big.Int, inputCallData []byte) (*evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxSendEvmTx builds and sends a MsgEthereumTx message based on the given call-data. The given sender account will be used to sign the message.

func (*ChainIntegrationTestSuite) TxSendEvmTxAsync

func (suite *ChainIntegrationTestSuite) TxSendEvmTxAsync(ctx sdk.Context, sender *itutiltypes.TestAccount, to *common.Address, amount *big.Int, inputCallData []byte) (*evmtypes.MsgEthereumTx, error)

TxSendEvmTxAsync is the same as TxSendEvmTx but with Async delivery mode.

func (*ChainIntegrationTestSuite) TxSendViaEVM

func (suite *ChainIntegrationTestSuite) TxSendViaEVM(from, to *itutiltypes.TestAccount, amount float64) (*evmtypes.MsgEthereumTx, error)

TxSendViaEVM sends amount of base coin from one to another, via EVM module

func (*ChainIntegrationTestSuite) TxSendViaEVMAsync

func (suite *ChainIntegrationTestSuite) TxSendViaEVMAsync(from, to *itutiltypes.TestAccount, amount float64) (*evmtypes.MsgEthereumTx, error)

TxSendViaEVMAsync is the same as TxSendViaEVM but with Async delivery mode.

func (*ChainIntegrationTestSuite) TxTransferErc20Token

func (suite *ChainIntegrationTestSuite) TxTransferErc20Token(contract common.Address, sender, receiver *itutiltypes.TestAccount, amount uint16, decimals uint8) (*evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxTransferErc20Token call the "transfer" function of the given ERC20 contract, transferring token from sender to receiver. Sender account will be used to call the function.

func (*ChainIntegrationTestSuite) TxTransferErc20TokenAsync

func (suite *ChainIntegrationTestSuite) TxTransferErc20TokenAsync(contract common.Address, sender, receiver *itutiltypes.TestAccount, amount uint16, decimals uint8) (*evmtypes.MsgEthereumTx, error)

TxTransferErc20TokenAsync is the same as TxTransferErc20Token but with Async delivery mode.

func (*ChainIntegrationTestSuite) TxTransferNft1155Token

func (suite *ChainIntegrationTestSuite) TxTransferNft1155Token(contract common.Address, abi abi.ABI, sender, receiver *itutiltypes.TestAccount, tokenId *big.Int, amount uint16) (*evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxTransferNft1155Token call the "safeTransferFrom" function of the given ERC-1155 contract, transferring give amount of given NFT token from sender to receiver.

func (*ChainIntegrationTestSuite) TxTransferNft1155TokenAsync

func (suite *ChainIntegrationTestSuite) TxTransferNft1155TokenAsync(contract common.Address, abi abi.ABI, sender, receiver *itutiltypes.TestAccount, tokenId *big.Int, amount uint16) (*evmtypes.MsgEthereumTx, error)

TxTransferNft1155TokenAsync is the same as TxTransferNft1155Token but with Async delivery mode.

func (*ChainIntegrationTestSuite) TxTransferNft721Token

func (suite *ChainIntegrationTestSuite) TxTransferNft721Token(contract common.Address, abi abi.ABI, sender, receiver *itutiltypes.TestAccount, tokenId *big.Int) (*evmtypes.MsgEthereumTx, *itutiltypes.ResponseDeliverEthTx, error)

TxTransferNft721Token call the "safeTransferFrom" function of the given ERC-721 contract, transferring a NFT token from sender to receiver. Sender account will be used to call the function.

func (*ChainIntegrationTestSuite) TxTransferNft721TokenAsync

func (suite *ChainIntegrationTestSuite) TxTransferNft721TokenAsync(contract common.Address, abi abi.ABI, sender, receiver *itutiltypes.TestAccount, tokenId *big.Int) (*evmtypes.MsgEthereumTx, error)

TxTransferNft721TokenAsync is the same as TxTransferNft721Token but with Async delivery mode.

func (*ChainIntegrationTestSuite) TxVote

func (suite *ChainIntegrationTestSuite) TxVote(voter *itutiltypes.TestAccount, proposalId uint64, option govv1types.VoteOption) error

TxVote submits a vote on given proposal.

func (*ChainIntegrationTestSuite) UseKeyring

func (suite *ChainIntegrationTestSuite) UseKeyring()

func (*ChainIntegrationTestSuite) WaitNextBlockOrCommit

func (suite *ChainIntegrationTestSuite) WaitNextBlockOrCommit() int64

WaitNextBlockOrCommit returns the most recent block height beside the following logic:

- When Tendermint is Enabled, it waits for the next block to be committed before returning result.

- When Tendermint is Disabled, it triggers commit block and starts a new block with an updated context.

USE-CASE for this: you want to submit one or multiple txs and have sometime to know the executed block, while Tendermint auto commit blocks.

type ChainsIbcIntegrationTestSuite

type ChainsIbcIntegrationTestSuite struct {
	Chain1        *ChainIntegrationTestSuite
	Chain2        *ChainIntegrationTestSuite
	TestChain1    *ibctesting.TestChain
	TestChain2    *ibctesting.TestChain
	RelayerChain1 *itutiltypes.TestAccount
	RelayerChain2 *itutiltypes.TestAccount
	Path          *ibctesting.Path
	Coordinator   *ibctesting.Coordinator
}

ChainsIbcIntegrationTestSuite is a wrapper of ChainIntegrationTestSuite for IBC testing. Tendermint is Disabled for IBC testing.

func CreateChainsIbcIntegrationTestSuite

func CreateChainsIbcIntegrationTestSuite(chain1, chain2 *ChainIntegrationTestSuite, relayer1, relayer2 *itutiltypes.TestAccount) *ChainsIbcIntegrationTestSuite

CreateChainsIbcIntegrationTestSuite initializes an IBC integration test suite from given chains. The input chain must disable Tendermint.

func (*ChainsIbcIntegrationTestSuite) Chain

func (suite *ChainsIbcIntegrationTestSuite) Chain(number int) (
	chainSuite *ChainIntegrationTestSuite,
	testChain *ibctesting.TestChain,
	relayer *itutiltypes.TestAccount,
	endpoint *ibctesting.Endpoint,
)

Chain returns the chain suite, test chain, relayer and endpoint of given chain by number.

func (*ChainsIbcIntegrationTestSuite) Cleanup

func (suite *ChainsIbcIntegrationTestSuite) Cleanup()

Cleanup performs cleanup tasks on each of the inner chains.

func (*ChainsIbcIntegrationTestSuite) CommitAllChains

func (suite *ChainsIbcIntegrationTestSuite) CommitAllChains()

CommitAllChains is a MUST call method when IBC testing, it performs commit on all inner chains. Due to the complicated logic of the chain test suite, this function is required to sync required data for all chains.

func (*ChainsIbcIntegrationTestSuite) TemporarySetBaseFeeZero

func (suite *ChainsIbcIntegrationTestSuite) TemporarySetBaseFeeZero() (releaser func())

TemporarySetBaseFeeZero is a helper function that used to bypass EIP-1559 by x/feemarket module.

It does temporarily set the base fee of all chains to 0 and returns a function that is used to restore the original base fee amount.

func (*ChainsIbcIntegrationTestSuite) TxMakeIbcTransfer

func (suite *ChainsIbcIntegrationTestSuite) TxMakeIbcTransfer(fromChain *ChainIntegrationTestSuite, fromTestChain *ibctesting.TestChain, fromEndpoint *ibctesting.Endpoint, toChain *ChainIntegrationTestSuite, sender, receiver *itutiltypes.TestAccount, transferCoin sdk.Coin) channeltypes.Packet

TxMakeIbcTransfer creates and submit an IBC transfer from given chain to another. The relayed packet will be returned.

func (*ChainsIbcIntegrationTestSuite) TxMakeIbcTransferFromChain2ToChain1

func (suite *ChainsIbcIntegrationTestSuite) TxMakeIbcTransferFromChain2ToChain1(receiver *itutiltypes.TestAccount, transferCoin sdk.Coin) channeltypes.Packet

TxMakeIbcTransferFromChain2ToChain1 creates and submit an IBC transfer from chain2 to chain1. The relayed packet will be returned.

type CosmosTxArgs

type CosmosTxArgs struct {
	// Gas to be used on the tx
	Gas uint64
	// GasPrice to use on tx
	GasPrice *sdkmath.Int
	// Fees is the fee to be used on the tx (amount and denom)
	Fees sdk.Coins
	// FeeGranter is the account address of the fee granter
	FeeGranter sdk.AccAddress
	// Msgs slice of messages to include on the tx
	Msgs []sdk.Msg
}

CosmosTxArgs contains the params to create a cosmos tx

type QueryServiceTestHelper

type QueryServiceTestHelper struct {
	*baseapp.GRPCQueryRouter
	Ctx sdk.Context
	// contains filtered or unexported fields
}

QueryServiceTestHelper provides a helper for making grpc query service rpc calls in unit tests. It implements both the grpc Server and ClientConn interfaces needed to register a query service server and create a query service client.

func NewQueryServerTestHelper

func NewQueryServerTestHelper(ctx sdk.Context, interfaceRegistry types.InterfaceRegistry) *QueryServiceTestHelper

NewQueryServerTestHelper creates a new QueryServiceTestHelper that wraps the provided sdk.Context.

This one is copied from baseapp of cosmos-sdk to add ability to include x-cosmos-block-height header

func (*QueryServiceTestHelper) Invoke

func (q *QueryServiceTestHelper) Invoke(_ gocontext.Context, method string, args, reply interface{}, callOptions ...grpc.CallOption) error

Invoke implements the grpc ClientConn.Invoke method

func (*QueryServiceTestHelper) NewStream

NewStream implements the grpc ClientConn.NewStream method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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