diff --git a/.github/workflows/e2e-conformance.yml b/.github/workflows/e2e-conformance.yml new file mode 100644 index 000000000..24e2c0235 --- /dev/null +++ b/.github/workflows/e2e-conformance.yml @@ -0,0 +1,32 @@ +name: Conformance End-To-End Tests + +on: + pull_request: + +# Ensures that only a single workflow per PR will run at a time. Cancels in-progress jobs if new commit is pushed. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test-conformance: + name: test-conformance + runs-on: ubuntu-latest + steps: + # Install and setup go + - name: Set up Go 1.22 + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: checkout interchaintest + uses: actions/checkout@v4 + + # cleanup environment on self-hosted test runner + - name: clean + run: |- + rm -rf ~/.interchaintest + + # run tests + - name: run conformance tests + run: (go test -race -timeout 30m -failfast -v -p 2 ./cmd/interchaintest) || (echo "\n\n*****CHAIN and RELAYER LOGS*****" && cat "$HOME/.interchaintest/logs/interchaintest.log" && exit 1) diff --git a/.github/workflows/e2e-cosmos.yml b/.github/workflows/e2e-cosmos.yml new file mode 100644 index 000000000..14a38b4dd --- /dev/null +++ b/.github/workflows/e2e-cosmos.yml @@ -0,0 +1,33 @@ +name: Cosmos End-To-End Tests + +on: + pull_request: + +# Ensures that only a single workflow per PR will run at a time. Cancels in-progress jobs if new commit is pushed. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test-cosmos-examples: + name: test-cosmos-examples + runs-on: ubuntu-latest + steps: + # Install and setup go + - name: Set up Go 1.22 + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: false + + - name: checkout interchaintest + uses: actions/checkout@v4 + + # cleanup environment on self-hosted test runner + - name: clean + run: |- + rm -rf ~/.interchaintest + + # run tests + - name: run example cosmos tests + run: go test -race -failfast -timeout 30m -v -p 2 ./examples/cosmos diff --git a/.github/workflows/e2e-ibc.yml b/.github/workflows/e2e-ibc.yml new file mode 100644 index 000000000..7538da63e --- /dev/null +++ b/.github/workflows/e2e-ibc.yml @@ -0,0 +1,33 @@ +name: IBC End-To-End Tests + +on: + pull_request: + +# Ensures that only a single workflow per PR will run at a time. Cancels in-progress jobs if new commit is pushed. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test-ibc-examples: + name: test-ibc-examples + runs-on: ubuntu-latest + steps: + # Install and setup go + - name: Set up Go 1.22 + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: false + + - name: checkout interchaintest + uses: actions/checkout@v4 + + # cleanup environment on self-hosted test runner + - name: clean + run: |- + rm -rf ~/.interchaintest + + # run tests + - name: run example ibc tests + run: go test -race -timeout 30m -failfast -v -p 2 ./examples/ibc diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml deleted file mode 100644 index 54f8a71a3..000000000 --- a/.github/workflows/e2e-tests.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Run End-To-End Tests - -on: - pull_request: - -# Ensures that only a single workflow per PR will run at a time. Cancels in-progress jobs if new commit is pushed. -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - test-conformance: - name: test-conformance - runs-on: ubuntu-latest - steps: - # Install and setup go - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: '1.22' - - - name: checkout interchaintest - uses: actions/checkout@v4 - - # cleanup environment on self-hosted test runner - - name: clean - run: |- - rm -rf ~/.interchaintest - - # run tests - - name: run conformance tests - run: (go test -race -timeout 30m -failfast -v -p 2 ./cmd/interchaintest) || (echo "\n\n*****CHAIN and RELAYER LOGS*****" && cat "$HOME/.interchaintest/logs/interchaintest.log" && exit 1) - test-ibc-examples: - name: test-ibc-examples - runs-on: ubuntu-latest - steps: - # Install and setup go - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: false - - - name: checkout interchaintest - uses: actions/checkout@v4 - - # cleanup environment on self-hosted test runner - - name: clean - run: |- - rm -rf ~/.interchaintest - - # run tests - - name: run example ibc tests - run: go test -race -timeout 30m -failfast -v -p 2 ./examples/ibc - test-cosmos-examples: - name: test-cosmos-examples - runs-on: ubuntu-latest - steps: - # Install and setup go - - name: Set up Go 1.22 - uses: actions/setup-go@v5 - with: - go-version: '1.22' - cache: false - - - name: checkout interchaintest - uses: actions/checkout@v4 - - # cleanup environment on self-hosted test runner - - name: clean - run: |- - rm -rf ~/.interchaintest - - # run tests - - name: run example cosmos tests - run: go test -race -failfast -timeout 30m -v -p 2 ./examples/cosmos diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 40440e00e..c0691dfb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: types: [created] env: - GO_VERSION: 1.21 + GO_VERSION: 1.22 jobs: release-static-binary: @@ -31,4 +31,4 @@ jobs: with: token: ${{ github.token }} files: | - local-ic \ No newline at end of file + local-ic diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 33c0c91c3..0323f8c95 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ Before you start contributing, make sure you have the following prerequisites in - [Go](https://golang.org/dl/) - [Docker](https://www.docker.com/get-started) -- [VSCode (recommended editor)](https://code.visualstudio.com/) +- [VSCode (recommended editor)](https://code.visualstudio.com/) To get started, follow these steps: @@ -76,7 +76,7 @@ To get started, follow these steps: git checkout -b name/broad-description-of-feature ``` -4. Make your changes and commit them with descriptive commit messages. +4. Make your changes and commit them with descriptive commit messages. 5. Test your changes locally with `go test ./...`, or by running the specific test affecting your feature or fix. @@ -86,4 +86,4 @@ To get started, follow these steps: git push origin name/broad-description-of-feature ``` -7. Create a pull request (PR) against the main branch of the interchaintest repository. If the PR is still a work-in-progress, please mark the PR as draft. \ No newline at end of file +7. Create a pull request (PR) against the main branch of the interchaintest repository. If the PR is still a work-in-progress, please mark the PR as draft. diff --git a/chain/cosmos/broadcaster.go b/chain/cosmos/broadcaster.go index b51ba1801..43afde424 100644 --- a/chain/cosmos/broadcaster.go +++ b/chain/cosmos/broadcaster.go @@ -103,7 +103,7 @@ func (b *Broadcaster) GetFactory(ctx context.Context, user User) (tx.Factory, er // client.Context. func (b *Broadcaster) GetClientContext(ctx context.Context, user User) (client.Context, error) { chain := b.chain - cn := chain.getFullNode() + cn := chain.GetFullNode() _, ok := b.keyrings[user] if !ok { @@ -160,7 +160,7 @@ func (b *Broadcaster) defaultClientContext(fromUser User, sdkAdd sdk.AccAddress) // initialize a clean buffer each time b.buf.Reset() kr := b.keyrings[fromUser] - cn := b.chain.getFullNode() + cn := b.chain.GetFullNode() return cn.CliContext(). WithOutput(b.buf). WithFrom(fromUser.FormattedAddress()). diff --git a/chain/cosmos/cosmos_chain.go b/chain/cosmos/cosmos_chain.go index 1096d4b54..e69472341 100644 --- a/chain/cosmos/cosmos_chain.go +++ b/chain/cosmos/cosmos_chain.go @@ -30,7 +30,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" @@ -155,7 +155,7 @@ func (c *CosmosChain) AddFullNodes(ctx context.Context, configFileOverrides map[ prevCount := c.numFullNodes c.numFullNodes += inc - if err := c.initializeChainNodes(ctx, c.testName, c.getFullNode().DockerClient, c.getFullNode().NetworkID); err != nil { + if err := c.initializeChainNodes(ctx, c.testName, c.GetFullNode().DockerClient, c.GetFullNode().NetworkID); err != nil { return err } @@ -211,7 +211,7 @@ func (c *CosmosChain) Initialize(ctx context.Context, testName string, cli *clie return c.initializeChainNodes(ctx, testName, cli, networkID) } -func (c *CosmosChain) getFullNode() *ChainNode { +func (c *CosmosChain) GetFullNode() *ChainNode { return c.GetNode() } @@ -221,75 +221,75 @@ func (c *CosmosChain) GetNode() *ChainNode { // Exec implements ibc.Chain. func (c *CosmosChain) Exec(ctx context.Context, cmd []string, env []string) (stdout, stderr []byte, err error) { - return c.getFullNode().Exec(ctx, cmd, env) + return c.GetFullNode().Exec(ctx, cmd, env) } // Implements Chain interface. func (c *CosmosChain) GetRPCAddress() string { if c.Config().UsesCometMock() { - return fmt.Sprintf("http://%s:22331", c.getFullNode().HostnameCometMock()) + return fmt.Sprintf("http://%s:22331", c.GetFullNode().HostnameCometMock()) } - return fmt.Sprintf("http://%s:26657", c.getFullNode().HostName()) + return fmt.Sprintf("http://%s:26657", c.GetFullNode().HostName()) } // Implements Chain interface. func (c *CosmosChain) GetAPIAddress() string { - return fmt.Sprintf("http://%s:1317", c.getFullNode().HostName()) + return fmt.Sprintf("http://%s:1317", c.GetFullNode().HostName()) } // Implements Chain interface. func (c *CosmosChain) GetGRPCAddress() string { - return fmt.Sprintf("%s:9090", c.getFullNode().HostName()) + return fmt.Sprintf("%s:9090", c.GetFullNode().HostName()) } // GetHostRPCAddress returns the address of the RPC server accessible by the host. // This will not return a valid address until the chain has been started. func (c *CosmosChain) GetHostRPCAddress() string { - return "http://" + c.getFullNode().hostRPCPort + return "http://" + c.GetFullNode().hostRPCPort } // GetHostAPIAddress returns the address of the REST API server accessible by the host. // This will not return a valid address until the chain has been started. func (c *CosmosChain) GetHostAPIAddress() string { - return "http://" + c.getFullNode().hostAPIPort + return "http://" + c.GetFullNode().hostAPIPort } // GetHostGRPCAddress returns the address of the gRPC server accessible by the host. // This will not return a valid address until the chain has been started. func (c *CosmosChain) GetHostGRPCAddress() string { - return c.getFullNode().hostGRPCPort + return c.GetFullNode().hostGRPCPort } // GetHostP2PAddress returns the address of the P2P server accessible by the host. // This will not return a valid address until the chain has been started. func (c *CosmosChain) GetHostPeerAddress() string { - return c.getFullNode().hostP2PPort + return c.GetFullNode().hostP2PPort } // HomeDir implements ibc.Chain. func (c *CosmosChain) HomeDir() string { - return c.getFullNode().HomeDir() + return c.GetFullNode().HomeDir() } // Implements Chain interface. func (c *CosmosChain) CreateKey(ctx context.Context, keyName string) error { - return c.getFullNode().CreateKey(ctx, keyName) + return c.GetFullNode().CreateKey(ctx, keyName) } // Implements Chain interface. func (c *CosmosChain) RecoverKey(ctx context.Context, keyName, mnemonic string) error { - return c.getFullNode().RecoverKey(ctx, keyName, mnemonic) + return c.GetFullNode().RecoverKey(ctx, keyName, mnemonic) } // Implements Chain interface. func (c *CosmosChain) GetAddress(ctx context.Context, keyName string) ([]byte, error) { - b32Addr, err := c.getFullNode().AccountKeyBech32(ctx, keyName) + b32Addr, err := c.GetFullNode().AccountKeyBech32(ctx, keyName) if err != nil { return nil, err } - return types.GetFromBech32(b32Addr, c.Config().Bech32Prefix) + return sdk.GetFromBech32(b32Addr, c.Config().Bech32Prefix) } // BuildWallet will return a Cosmos wallet @@ -344,12 +344,12 @@ func (c *CosmosChain) BuildRelayerWallet(ctx context.Context, keyName string) (i // Implements Chain interface. func (c *CosmosChain) SendFunds(ctx context.Context, keyName string, amount ibc.WalletAmount) error { - return c.getFullNode().BankSend(ctx, keyName, amount) + return c.GetFullNode().BankSend(ctx, keyName, amount) } // Implements Chain interface. func (c *CosmosChain) SendFundsWithNote(ctx context.Context, keyName string, amount ibc.WalletAmount, note string) (string, error) { - return c.getFullNode().BankSendWithNote(ctx, keyName, amount, note) + return c.GetFullNode().BankSendWithNote(ctx, keyName, amount, note) } // Implements Chain interface. @@ -360,7 +360,7 @@ func (c *CosmosChain) SendIBCTransfer( amount ibc.WalletAmount, options ibc.TransferOptions, ) (tx ibc.Tx, _ error) { - txHash, err := c.getFullNode().SendIBCTransfer(ctx, channelID, keyName, amount, options) + txHash, err := c.GetFullNode().SendIBCTransfer(ctx, channelID, keyName, amount, options) if err != nil { return tx, fmt.Errorf("send ibc transfer: %w", err) } @@ -418,18 +418,18 @@ func (c *CosmosChain) SendIBCTransfer( // RegisterICA will attempt to register an interchain account on the given counterparty chain. func (c *CosmosChain) RegisterICA(ctx context.Context, keyName string, connectionID string) (string, error) { - return c.getFullNode().RegisterICA(ctx, keyName, connectionID) + return c.GetFullNode().RegisterICA(ctx, keyName, connectionID) } // QueryICA will query for an interchain account controlled by the given address on the counterparty chain. func (c *CosmosChain) QueryICAAddress(ctx context.Context, connectionID, address string) (string, error) { - return c.getFullNode().QueryICA(ctx, connectionID, address) + return c.GetFullNode().QueryICA(ctx, connectionID, address) } // SendICATx sends an interchain account transaction for a specified address and sends it to the respective // interchain account on the counterparty chain. -func (c *CosmosChain) SendICATx(ctx context.Context, keyName, connectionID string, msgs []types.Msg, icaTxMemo string) (string, error) { - node := c.getFullNode() +func (c *CosmosChain) SendICATx(ctx context.Context, keyName, connectionID string, msgs []sdk.Msg, icaTxMemo string) (string, error) { + node := c.GetFullNode() registry := node.Chain.Config().EncodingConfig.InterfaceRegistry encoding := "proto3" return node.SendICATx(ctx, keyName, connectionID, registry, msgs, icaTxMemo, encoding) @@ -449,7 +449,7 @@ func (c *CosmosChain) PushNewWasmClientProposal(ctx context.Context, keyName str return tx, "", err } message := wasmtypes.MsgStoreCode{ - Signer: types.MustBech32ifyAddressBytes(c.cfg.Bech32Prefix, authtypes.NewModuleAddress(govtypes.ModuleName)), + Signer: sdk.MustBech32ifyAddressBytes(c.cfg.Bech32Prefix, authtypes.NewModuleAddress(govtypes.ModuleName)), WasmByteCode: content, } msg, err := c.cfg.EncodingConfig.Codec.MarshalInterfaceJSON(&message) @@ -457,7 +457,7 @@ func (c *CosmosChain) PushNewWasmClientProposal(ctx context.Context, keyName str return tx, "", err } prop.Messages = append(prop.Messages, msg) - txHash, err := c.getFullNode().SubmitProposal(ctx, keyName, prop) + txHash, err := c.GetFullNode().SubmitProposal(ctx, keyName, prop) if err != nil { return tx, "", fmt.Errorf("failed to submit wasm client proposal: %w", err) } @@ -467,7 +467,7 @@ func (c *CosmosChain) PushNewWasmClientProposal(ctx context.Context, keyName str // UpgradeProposal submits a software-upgrade governance proposal to the chain. func (c *CosmosChain) UpgradeProposal(ctx context.Context, keyName string, prop SoftwareUpgradeProposal) (tx TxProposal, _ error) { - txHash, err := c.getFullNode().UpgradeProposal(ctx, keyName, prop) + txHash, err := c.GetFullNode().UpgradeProposal(ctx, keyName, prop) if err != nil { return tx, fmt.Errorf("failed to submit upgrade proposal: %w", err) } @@ -476,7 +476,7 @@ func (c *CosmosChain) UpgradeProposal(ctx context.Context, keyName string, prop // SubmitProposal submits a gov v1 proposal to the chain. func (c *CosmosChain) SubmitProposal(ctx context.Context, keyName string, prop TxProposalv1) (tx TxProposal, _ error) { - txHash, err := c.getFullNode().SubmitProposal(ctx, keyName, prop) + txHash, err := c.GetFullNode().SubmitProposal(ctx, keyName, prop) if err != nil { return tx, fmt.Errorf("failed to submit gov v1 proposal: %w", err) } @@ -485,7 +485,7 @@ func (c *CosmosChain) SubmitProposal(ctx context.Context, keyName string, prop T // TextProposal submits a text governance proposal to the chain. func (c *CosmosChain) TextProposal(ctx context.Context, keyName string, prop TextProposal) (tx TxProposal, _ error) { - txHash, err := c.getFullNode().TextProposal(ctx, keyName, prop) + txHash, err := c.GetFullNode().TextProposal(ctx, keyName, prop) if err != nil { return tx, fmt.Errorf("failed to submit upgrade proposal: %w", err) } @@ -494,7 +494,7 @@ func (c *CosmosChain) TextProposal(ctx context.Context, keyName string, prop Tex // ParamChangeProposal submits a param change proposal to the chain, signed by keyName. func (c *CosmosChain) ParamChangeProposal(ctx context.Context, keyName string, prop *paramsutils.ParamChangeProposalJSON) (tx TxProposal, _ error) { - txHash, err := c.getFullNode().ParamChangeProposal(ctx, keyName, prop) + txHash, err := c.GetFullNode().ParamChangeProposal(ctx, keyName, prop) if err != nil { return tx, fmt.Errorf("failed to submit param change proposal: %w", err) } @@ -504,17 +504,17 @@ func (c *CosmosChain) ParamChangeProposal(ctx context.Context, keyName string, p // QueryParam returns the param state of a given key. func (c *CosmosChain) QueryParam(ctx context.Context, subspace, key string) (*ParamChange, error) { - return c.getFullNode().QueryParam(ctx, subspace, key) + return c.GetFullNode().QueryParam(ctx, subspace, key) } // QueryBankMetadata returns the metadata of a given token denomination. func (c *CosmosChain) QueryBankMetadata(ctx context.Context, denom string) (*BankMetaData, error) { - return c.getFullNode().QueryBankMetadata(ctx, denom) + return c.GetFullNode().QueryBankMetadata(ctx, denom) } // ConsumerAdditionProposal submits a legacy governance proposal to add a consumer to the chain. func (c *CosmosChain) ConsumerAdditionProposal(ctx context.Context, keyName string, prop ccvclient.ConsumerAdditionProposalJSON) (tx TxProposal, _ error) { - txHash, err := c.getFullNode().ConsumerAdditionProposal(ctx, keyName, prop) + txHash, err := c.GetFullNode().ConsumerAdditionProposal(ctx, keyName, prop) if err != nil { return tx, fmt.Errorf("failed to submit consumer addition proposal: %w", err) } @@ -543,57 +543,57 @@ func (c *CosmosChain) txProposal(txHash string) (tx TxProposal, _ error) { // StoreContract takes a file path to smart contract and stores it on-chain. Returns the contracts code id. func (c *CosmosChain) StoreContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) { - return c.getFullNode().StoreContract(ctx, keyName, fileName, extraExecTxArgs...) + return c.GetFullNode().StoreContract(ctx, keyName, fileName, extraExecTxArgs...) } // InstantiateContract takes a code id for a smart contract and initialization message and returns the instantiated contract address. func (c *CosmosChain) InstantiateContract(ctx context.Context, keyName string, codeID string, initMessage string, needsNoAdminFlag bool, extraExecTxArgs ...string) (string, error) { - return c.getFullNode().InstantiateContract(ctx, keyName, codeID, initMessage, needsNoAdminFlag, extraExecTxArgs...) + return c.GetFullNode().InstantiateContract(ctx, keyName, codeID, initMessage, needsNoAdminFlag, extraExecTxArgs...) } // ExecuteContract executes a contract transaction with a message using it's address. -func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string, extraExecTxArgs ...string) (res *types.TxResponse, err error) { - return c.getFullNode().ExecuteContract(ctx, keyName, contractAddress, message, extraExecTxArgs...) +func (c *CosmosChain) ExecuteContract(ctx context.Context, keyName string, contractAddress string, message string, extraExecTxArgs ...string) (res *sdk.TxResponse, err error) { + return c.GetFullNode().ExecuteContract(ctx, keyName, contractAddress, message, extraExecTxArgs...) } // MigrateContract performs contract migration. -func (c *CosmosChain) MigrateContract(ctx context.Context, keyName string, contractAddress string, codeID string, message string, extraExecTxArgs ...string) (res *types.TxResponse, err error) { - return c.getFullNode().MigrateContract(ctx, keyName, contractAddress, codeID, message, extraExecTxArgs...) +func (c *CosmosChain) MigrateContract(ctx context.Context, keyName string, contractAddress string, codeID string, message string, extraExecTxArgs ...string) (res *sdk.TxResponse, err error) { + return c.GetFullNode().MigrateContract(ctx, keyName, contractAddress, codeID, message, extraExecTxArgs...) } // QueryContract performs a smart query, taking in a query struct and returning a error with the response struct populated. func (c *CosmosChain) QueryContract(ctx context.Context, contractAddress string, query any, response any) error { - return c.getFullNode().QueryContract(ctx, contractAddress, query, response) + return c.GetFullNode().QueryContract(ctx, contractAddress, query, response) } // DumpContractState dumps the state of a contract at a block height. func (c *CosmosChain) DumpContractState(ctx context.Context, contractAddress string, height int64) (*DumpContractStateResponse, error) { - return c.getFullNode().DumpContractState(ctx, contractAddress, height) + return c.GetFullNode().DumpContractState(ctx, contractAddress, height) } // StoreClientContract takes a file path to a client smart contract and stores it on-chain. Returns the contracts code id. func (c *CosmosChain) StoreClientContract(ctx context.Context, keyName string, fileName string, extraExecTxArgs ...string) (string, error) { - return c.getFullNode().StoreClientContract(ctx, keyName, fileName, extraExecTxArgs...) + return c.GetFullNode().StoreClientContract(ctx, keyName, fileName, extraExecTxArgs...) } // QueryClientContractCode performs a query with the contract codeHash as the input and code as the output. func (c *CosmosChain) QueryClientContractCode(ctx context.Context, codeHash string, response any) error { - return c.getFullNode().QueryClientContractCode(ctx, codeHash, response) + return c.GetFullNode().QueryClientContractCode(ctx, codeHash, response) } // ExportState exports the chain state at specific height. // Implements Chain interface. func (c *CosmosChain) ExportState(ctx context.Context, height int64) (string, error) { - return c.getFullNode().ExportState(ctx, height) + return c.GetFullNode().ExportState(ctx, height) } // QueryContractInfo queries the chain for the contract metadata. func (c *CosmosChain) QueryContractInfo(ctx context.Context, contractAddress string) (*ContractInfoResponse, error) { - return c.getFullNode().QueryContractInfo(ctx, contractAddress) + return c.GetFullNode().QueryContractInfo(ctx, contractAddress) } -func (c *CosmosChain) GetTransaction(txhash string) (*types.TxResponse, error) { - fn := c.getFullNode() +func (c *CosmosChain) GetTransaction(txhash string) (*sdk.TxResponse, error) { + fn := c.GetFullNode() return fn.GetTransaction(fn.CliContext(), txhash) } @@ -844,15 +844,15 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene decimalPow := int64(math.Pow10(int(*chainCfg.CoinDecimals))) - genesisAmounts := make([][]types.Coin, len(c.Validators)) - genesisSelfDelegation := make([]types.Coin, len(c.Validators)) + genesisAmounts := make([][]sdk.Coin, len(c.Validators)) + genesisSelfDelegation := make([]sdk.Coin, len(c.Validators)) for i := range c.Validators { - genesisAmounts[i] = []types.Coin{{Amount: sdkmath.NewInt(10_000_000).MulRaw(decimalPow), Denom: chainCfg.Denom}} - genesisSelfDelegation[i] = types.Coin{Amount: sdkmath.NewInt(5_000_000).MulRaw(decimalPow), Denom: chainCfg.Denom} + genesisAmounts[i] = []sdk.Coin{{Amount: sdkmath.NewInt(10_000_000).MulRaw(decimalPow), Denom: chainCfg.Denom}} + genesisSelfDelegation[i] = sdk.Coin{Amount: sdkmath.NewInt(5_000_000).MulRaw(decimalPow), Denom: chainCfg.Denom} if chainCfg.ModifyGenesisAmounts != nil { amount, selfDelegation := chainCfg.ModifyGenesisAmounts(i) - genesisAmounts[i] = []types.Coin{amount} + genesisAmounts[i] = []sdk.Coin{amount} genesisSelfDelegation[i] = selfDelegation } } @@ -958,7 +958,7 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene } for _, wallet := range additionalGenesisWallets { - if err := validator0.AddGenesisAccount(ctx, wallet.Address, []types.Coin{{Denom: wallet.Denom, Amount: wallet.Amount}}); err != nil { + if err := validator0.AddGenesisAccount(ctx, wallet.Address, []sdk.Coin{{Denom: wallet.Denom, Amount: wallet.Amount}}); err != nil { return err } } @@ -1055,18 +1055,18 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene } // Wait for blocks before considering the chains "started" - return testutil.WaitForBlocks(ctx, 2, c.getFullNode()) + return testutil.WaitForBlocks(ctx, 2, c.GetFullNode()) } // Height implements ibc.Chain. func (c *CosmosChain) Height(ctx context.Context) (int64, error) { - return c.getFullNode().Height(ctx) + return c.GetFullNode().Height(ctx) } // Acknowledgements implements ibc.Chain, returning all acknowledgments in block at height. func (c *CosmosChain) Acknowledgements(ctx context.Context, height int64) ([]ibc.PacketAcknowledgement, error) { var acks []*chanTypes.MsgAcknowledgement - err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.getFullNode().Client, height, func(msg types.Msg) bool { + err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.GetFullNode().Client, height, func(msg sdk.Msg) bool { found, ok := msg.(*chanTypes.MsgAcknowledgement) if ok { acks = append(acks, found) @@ -1098,7 +1098,7 @@ func (c *CosmosChain) Acknowledgements(ctx context.Context, height int64) ([]ibc // Timeouts implements ibc.Chain, returning all timeouts in block at height. func (c *CosmosChain) Timeouts(ctx context.Context, height int64) ([]ibc.PacketTimeout, error) { var timeouts []*chanTypes.MsgTimeout - err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.getFullNode().Client, height, func(msg types.Msg) bool { + err := RangeBlockMessages(ctx, c.cfg.EncodingConfig.InterfaceRegistry, c.GetFullNode().Client, height, func(msg sdk.Msg) bool { found, ok := msg.(*chanTypes.MsgTimeout) if ok { timeouts = append(timeouts, found) @@ -1128,7 +1128,7 @@ func (c *CosmosChain) Timeouts(ctx context.Context, height int64) ([]ibc.PacketT // FindTxs implements blockdb.BlockSaver. func (c *CosmosChain) FindTxs(ctx context.Context, height int64) ([]blockdb.Tx, error) { - fn := c.getFullNode() + fn := c.GetFullNode() c.findTxMu.Lock() defer c.findTxMu.Unlock() return fn.FindTxs(ctx, height) diff --git a/chain/cosmos/ics.go b/chain/cosmos/ics.go index 892da244c..7a731031b 100644 --- a/chain/cosmos/ics.go +++ b/chain/cosmos/ics.go @@ -130,7 +130,7 @@ func (c *CosmosChain) StartProvider(testName string, ctx context.Context, additi return fmt.Errorf("failed to add proposer key: %s", err) } - proposerAddr, err := c.getFullNode().AccountKeyBech32(ctx, proposerKeyName) + proposerAddr, err := c.GetFullNode().AccountKeyBech32(ctx, proposerKeyName) if err != nil { return fmt.Errorf("failed to get proposer key: %s", err) } @@ -404,7 +404,7 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi } // Wait for 5 blocks before considering the chains "started" - return testutil.WaitForBlocks(ctx, 5, c.getFullNode()) + return testutil.WaitForBlocks(ctx, 5, c.GetFullNode()) } func (c *CosmosChain) transformCCVState(ctx context.Context, ccvState []byte, consumerVersion, providerVersion string, icsCfg ibc.ICSConfig) ([]byte, error) { diff --git a/chain/cosmos/module_tokenfactory.go b/chain/cosmos/module_tokenfactory.go index 76f16a7bd..ae35f66d0 100644 --- a/chain/cosmos/module_tokenfactory.go +++ b/chain/cosmos/module_tokenfactory.go @@ -87,7 +87,7 @@ func (tn *ChainNode) TokenFactoryMetadata(ctx context.Context, keyName, fullDeno // TokenFactoryQueryAdmin returns the admin of a tokenfactory token. func (c *CosmosChain) TokenFactoryQueryAdmin(ctx context.Context, fullDenom string) (*QueryDenomAuthorityMetadataResponse, error) { res := &QueryDenomAuthorityMetadataResponse{} - stdout, stderr, err := c.getFullNode().ExecQuery(ctx, "tokenfactory", "denom-authority-metadata", fullDenom) + stdout, stderr, err := c.GetFullNode().ExecQuery(ctx, "tokenfactory", "denom-authority-metadata", fullDenom) if err != nil { return nil, fmt.Errorf("failed to query tokenfactory denom-authority-metadata: %w\nstdout: %s\nstderr: %s", err, stdout, stderr) } diff --git a/chain/cosmos/osmosis.go b/chain/cosmos/osmosis.go index c6ecbb77f..f850d0a4c 100644 --- a/chain/cosmos/osmosis.go +++ b/chain/cosmos/osmosis.go @@ -20,7 +20,7 @@ type OsmosisPoolParams struct { } func OsmosisCreatePool(c *CosmosChain, ctx context.Context, keyName string, params OsmosisPoolParams) (string, error) { - tn := c.getFullNode() + tn := c.GetFullNode() poolbz, err := json.Marshal(params) if err != nil { return "", err @@ -57,7 +57,7 @@ func OsmosisCreatePool(c *CosmosChain, ctx context.Context, keyName string, para } func OsmosisSwapExactAmountIn(c *CosmosChain, ctx context.Context, keyName string, coinIn string, minAmountOut string, poolIDs []string, swapDenoms []string) (string, error) { - return c.getFullNode().ExecTx(ctx, keyName, + return c.GetFullNode().ExecTx(ctx, keyName, "gamm", "swap-exact-amount-in", coinIn, minAmountOut, "--swap-route-pool-ids", strings.Join(poolIDs, ","), diff --git a/chain/cosmos/poll.go b/chain/cosmos/poll.go index 72ccffeb8..0d6fa8908 100644 --- a/chain/cosmos/poll.go +++ b/chain/cosmos/poll.go @@ -58,7 +58,7 @@ func PollForMessage[T any](ctx context.Context, chain *CosmosChain, registry cod } doPoll := func(ctx context.Context, height int64) (T, error) { h := height - block, err := chain.getFullNode().Client.Block(ctx, &h) + block, err := chain.GetFullNode().Client.Block(ctx, &h) if err != nil { return zero, err } diff --git a/cmd/interchaintest/interchaintest_test.go b/cmd/interchaintest/interchaintest_test.go index 32320fc7a..ec7c52bf3 100644 --- a/cmd/interchaintest/interchaintest_test.go +++ b/cmd/interchaintest/interchaintest_test.go @@ -21,6 +21,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/ibc" "github.com/strangelove-ventures/interchaintest/v8/relayer" "github.com/strangelove-ventures/interchaintest/v8/testreporter" + "github.com/strangelove-ventures/interchaintest/v8/testutil" ) func init() { @@ -101,11 +102,14 @@ func setUpTestMatrix() error { if extraFlags.MatrixFile == "" { fmt.Fprintln(os.Stderr, "No matrix file provided, falling back to rly with gaia and osmosis") + numValsOne := 1 + numFullNodesZero := 0 + testMatrix.Relayers = []string{"rly", "hermes"} testMatrix.ChainSets = [][]*interchaintest.ChainSpec{ { - {Name: "gaia", Version: "v7.0.1"}, - {Name: "osmosis", Version: "v7.2.0"}, + {Name: testutil.TestSimd, Version: testutil.SimdVersion, ChainName: "c1", NumValidators: &numValsOne, NumFullNodes: &numFullNodesZero}, + {Name: testutil.TestSimd, Version: testutil.SimdVersion, ChainName: "c2", NumValidators: &numValsOne, NumFullNodes: &numFullNodesZero}, }, } diff --git a/docs/ciTests.md b/docs/ciTests.md index 3b740c569..22764377b 100644 --- a/docs/ciTests.md +++ b/docs/ciTests.md @@ -18,7 +18,7 @@ Seamlessly build and test current iterations of your chain both locally and with We recommend creating a separate directory in your chain's repo and importing Interchaintest as its own module. This will allow you to keep the extra imports needed for `interchaintest` separate from your chain. -See [`noble`](https://github.com/strangelove-ventures/noble) chains `interchaintest` [folder](https://github.com/strangelove-ventures/noble/tree/main/interchaintest) as an example. +See [`noble`](https://github.com/noble-assets/noble) chains `interchaintest e2e` [folder](https://github.com/noble-assets/noble/tree/main/e2e) as an example. Nobles' CI workflow is a great example to follow along with throughout this guide. diff --git a/examples/cosmos/bad_genesis_params_test.go b/examples/cosmos/bad_genesis_params_test.go index f39e83542..abbc59453 100644 --- a/examples/cosmos/bad_genesis_params_test.go +++ b/examples/cosmos/bad_genesis_params_test.go @@ -16,6 +16,10 @@ var badGenesis = []cosmos.GenesisKV{ } func TestBadInputParams(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } + cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { Name: "juno", diff --git a/blockdb/messages_view_test.go b/examples/cosmos/blockdb_messages_view_test.go similarity index 81% rename from blockdb/messages_view_test.go rename to examples/cosmos/blockdb_messages_view_test.go index ae4e0c0ee..2a0bbd9ae 100644 --- a/blockdb/messages_view_test.go +++ b/examples/cosmos/blockdb_messages_view_test.go @@ -1,7 +1,4 @@ -package blockdb_test - -// This test is in a separate file, so it can be in the blockdb_test package, -// so it can import interchaintest without creating an import cycle. +package cosmos_test import ( "context" @@ -23,7 +20,7 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" ) -func TestMessagesView(t *testing.T) { +func TestBlockDBMessagesView(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } @@ -32,11 +29,11 @@ func TestMessagesView(t *testing.T) { client, network := interchaintest.DockerSetup(t) - const gaia0ChainID = "g0" - const gaia1ChainID = "g1" + const chainID0 = "c0" + const chainID1 = "c1" cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ - {Name: "gaia", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: gaia0ChainID}}, - {Name: "gaia", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: gaia1ChainID}}, + {Name: testutil.TestSimd, Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: chainID0}, NumValidators: &numVals, NumFullNodes: &numFullNodes}, + {Name: testutil.TestSimd, Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: chainID1}, NumValidators: &numVals, NumFullNodes: &numFullNodes}, }) chains, err := cf.Chains(t.Name()) @@ -93,7 +90,7 @@ func TestMessagesView(t *testing.T) { // Generate the path. // No transactions happen here. const pathName = "p" - require.NoError(t, r.GeneratePath(ctx, eRep, gaia0ChainID, gaia1ChainID, pathName)) + require.NoError(t, r.GeneratePath(ctx, eRep, chainID0, chainID1, pathName)) t.Run("create clients", func(t *testing.T) { // Creating the clients will cause transactions. @@ -105,11 +102,11 @@ client_chain_id FROM v_cosmos_messages WHERE type = "/ibc.core.client.v1.MsgCreateClient" AND chain_id = ?;` var clientChainID string - require.NoError(t, db.QueryRow(qCreateClient, gaia0ChainID).Scan(&clientChainID)) - require.Equal(t, gaia1ChainID, clientChainID) + require.NoError(t, db.QueryRow(qCreateClient, chainID0).Scan(&clientChainID)) + require.Equal(t, chainID1, clientChainID) - require.NoError(t, db.QueryRow(qCreateClient, gaia1ChainID).Scan(&clientChainID)) - require.Equal(t, gaia0ChainID, clientChainID) + require.NoError(t, db.QueryRow(qCreateClient, chainID1).Scan(&clientChainID)) + require.Equal(t, chainID0, clientChainID) }) if t.Failed() { return @@ -126,7 +123,7 @@ WHERE type = "/ibc.core.client.v1.MsgCreateClient" AND chain_id = ?;` // Wait for another block before retrieving the connections and querying for them. require.NoError(t, testutil.WaitForBlocks(ctx, 1, gaia0, gaia1)) - conns, err := r.GetConnections(ctx, eRep, gaia0ChainID) + conns, err := r.GetConnections(ctx, eRep, chainID0) require.NoError(t, err) // Collect the reported client IDs. @@ -142,7 +139,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.core.connection.v1.MsgConnectionOpenInit" AND chain_id = ? ` var clientID, counterpartyClientID string - require.NoError(t, db.QueryRow(qConnectionOpenInit, gaia0ChainID).Scan(&clientID, &counterpartyClientID)) + require.NoError(t, db.QueryRow(qConnectionOpenInit, chainID0).Scan(&clientID, &counterpartyClientID)) require.Equal(t, clientID, gaia0ClientID) require.Equal(t, counterpartyClientID, gaia1ClientID) @@ -153,7 +150,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.core.connection.v1.MsgConnectionOpenTry" AND chain_id = ? ` var counterpartyConnID string - require.NoError(t, db.QueryRow(qConnectionOpenTry, gaia1ChainID).Scan(&counterpartyClientID, &counterpartyConnID)) + require.NoError(t, db.QueryRow(qConnectionOpenTry, chainID1).Scan(&counterpartyClientID, &counterpartyConnID)) require.Equal(t, counterpartyClientID, gaia0ClientID) require.Equal(t, counterpartyConnID, gaia0ConnID) @@ -164,7 +161,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.core.connection.v1.MsgConnectionOpenAck" AND chain_id = ? ` var connID string - require.NoError(t, db.QueryRow(qConnectionOpenAck, gaia0ChainID).Scan(&connID, &counterpartyConnID)) + require.NoError(t, db.QueryRow(qConnectionOpenAck, chainID0).Scan(&connID, &counterpartyConnID)) require.Equal(t, connID, gaia0ConnID) require.Equal(t, counterpartyConnID, gaia1ConnID) @@ -174,7 +171,7 @@ conn_id FROM v_cosmos_messages WHERE type = "/ibc.core.connection.v1.MsgConnectionOpenConfirm" AND chain_id = ? ` - require.NoError(t, db.QueryRow(qConnectionOpenConfirm, gaia1ChainID).Scan(&connID)) + require.NoError(t, db.QueryRow(qConnectionOpenConfirm, chainID1).Scan(&connID)) require.Equal(t, connID, gaia0ConnID) // Not sure if this should be connection 0 or 1, as they are typically equal during this test. }) if t.Failed() { @@ -194,7 +191,7 @@ WHERE type = "/ibc.core.connection.v1.MsgConnectionOpenConfirm" AND chain_id = ? // Wait for another block before retrieving the channels and querying for them. require.NoError(t, testutil.WaitForBlocks(ctx, 1, gaia0, gaia1)) - channels, err := r.GetChannels(ctx, eRep, gaia0ChainID) + channels, err := r.GetChannels(ctx, eRep, chainID0) require.NoError(t, err) require.Len(t, channels, 1) @@ -208,7 +205,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.core.channel.v1.MsgChannelOpenInit" AND chain_id = ? ` var portID, counterpartyPortID string - require.NoError(t, db.QueryRow(qChannelOpenInit, gaia0ChainID).Scan(&portID, &counterpartyPortID)) + require.NoError(t, db.QueryRow(qChannelOpenInit, chainID0).Scan(&portID, &counterpartyPortID)) require.Equal(t, gaia0Port, portID) require.Equal(t, gaia1Port, counterpartyPortID) @@ -219,7 +216,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.core.channel.v1.MsgChannelOpenTry" AND chain_id = ? ` var counterpartyChannelID string - require.NoError(t, db.QueryRow(qChannelOpenTry, gaia1ChainID).Scan(&portID, &counterpartyPortID, &counterpartyChannelID)) + require.NoError(t, db.QueryRow(qChannelOpenTry, chainID1).Scan(&portID, &counterpartyPortID, &counterpartyChannelID)) require.Equal(t, gaia1Port, portID) require.Equal(t, gaia0Port, counterpartyPortID) require.Equal(t, counterpartyChannelID, gaia0ChannelID) @@ -231,7 +228,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.core.channel.v1.MsgChannelOpenAck" AND chain_id = ? ` var channelID string - require.NoError(t, db.QueryRow(qChannelOpenAck, gaia0ChainID).Scan(&portID, &channelID, &counterpartyChannelID)) + require.NoError(t, db.QueryRow(qChannelOpenAck, chainID0).Scan(&portID, &channelID, &counterpartyChannelID)) require.Equal(t, gaia0Port, portID) require.Equal(t, channelID, gaia0ChannelID) require.Equal(t, counterpartyChannelID, gaia1ChannelID) @@ -242,7 +239,7 @@ port_id, channel_id FROM v_cosmos_messages WHERE type = "/ibc.core.channel.v1.MsgChannelOpenConfirm" AND chain_id = ? ` - require.NoError(t, db.QueryRow(qChannelOpenConfirm, gaia1ChainID).Scan(&portID, &channelID)) + require.NoError(t, db.QueryRow(qChannelOpenConfirm, chainID1).Scan(&portID, &channelID)) require.Equal(t, gaia1Port, portID) require.Equal(t, channelID, gaia1ChannelID) }) @@ -274,7 +271,7 @@ FROM v_cosmos_messages WHERE type = "/ibc.applications.transfer.v1.MsgTransfer" AND chain_id = ? ` var portID, channelID string - require.NoError(t, db.QueryRow(qMsgTransfer, gaia0ChainID).Scan(&portID, &channelID)) + require.NoError(t, db.QueryRow(qMsgTransfer, chainID0).Scan(&portID, &channelID)) require.Equal(t, gaia0Port, portID) require.Equal(t, channelID, gaia0ChannelID) }) @@ -298,7 +295,7 @@ WHERE type = "/ibc.core.channel.v1.MsgRecvPacket" AND chain_id = ? var portID, channelID, counterpartyPortID, counterpartyChannelID string - require.NoError(t, db.QueryRow(qMsgRecvPacket, gaia1ChainID).Scan(&portID, &channelID, &counterpartyPortID, &counterpartyChannelID)) + require.NoError(t, db.QueryRow(qMsgRecvPacket, chainID1).Scan(&portID, &channelID, &counterpartyPortID, &counterpartyChannelID)) require.Equal(t, gaia0Port, portID) require.Equal(t, channelID, gaia0ChannelID) @@ -310,7 +307,7 @@ port_id, channel_id, counterparty_port_id, counterparty_channel_id FROM v_cosmos_messages WHERE type = "/ibc.core.channel.v1.MsgAcknowledgement" AND chain_id = ? ` - require.NoError(t, db.QueryRow(qMsgAck, gaia0ChainID).Scan(&portID, &channelID, &counterpartyPortID, &counterpartyChannelID)) + require.NoError(t, db.QueryRow(qMsgAck, chainID0).Scan(&portID, &channelID, &counterpartyPortID, &counterpartyChannelID)) require.Equal(t, gaia0Port, portID) require.Equal(t, channelID, gaia0ChannelID) diff --git a/examples/cosmos/chain_genesis_stake_test.go b/examples/cosmos/chain_genesis_stake_test.go index 962213845..8f0c39bda 100644 --- a/examples/cosmos/chain_genesis_stake_test.go +++ b/examples/cosmos/chain_genesis_stake_test.go @@ -34,6 +34,7 @@ func TestChainGenesisUnequalStake(t *testing.T) { ChainName: "gaia", Version: "v15.1.0", NumValidators: &validators, + NumFullNodes: &numFullNodesZero, ChainConfig: ibc.ChainConfig{ Denom: denom, ModifyGenesisAmounts: func(i int) (sdk.Coin, sdk.Coin) { diff --git a/examples/cosmos/chain_param_change_test.go b/examples/cosmos/chain_param_change_test.go index 74851e8dc..881239520 100644 --- a/examples/cosmos/chain_param_change_test.go +++ b/examples/cosmos/chain_param_change_test.go @@ -26,9 +26,6 @@ func CosmosChainParamChangeTest(t *testing.T, name, version string) { t.Parallel() - numVals := 1 - numFullNodes := 1 - // SDK v45 params for Juno genesis shortVoteGenesis := []cosmos.GenesisKV{ cosmos.NewGenesisKV("app_state.gov.voting_params.voting_period", votingPeriod), @@ -41,7 +38,7 @@ func CosmosChainParamChangeTest(t *testing.T, name, version string) { ModifyGenesis: cosmos.ModifyGenesis(shortVoteGenesis), } - chains := interchaintest.CreateChainWithConfig(t, numVals, numFullNodes, name, version, cfg) + chains := interchaintest.CreateChainWithConfig(t, numVals, numFullNodesZero, name, version, cfg) chain := chains[0].(*cosmos.CosmosChain) enableBlockDB := false diff --git a/examples/cosmos/code_coverage_test.go b/examples/cosmos/code_coverage_test.go index 0a1181782..9ca4d0a3c 100644 --- a/examples/cosmos/code_coverage_test.go +++ b/examples/cosmos/code_coverage_test.go @@ -16,14 +16,16 @@ import ( ) func TestCodeCoverage(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } + t.Parallel() var ( ctx = context.Background() ExternalGoCoverDir = "/tmp/interchaintest-app-coverage" Denom = "umfx" - vals = 1 - fullNodes = 0 ) cfgA := ibc.ChainConfig{ @@ -53,8 +55,8 @@ func TestCodeCoverage(t *testing.T) { Name: "manifest", Version: cfgA.Images[0].Version, ChainName: cfgA.Name, - NumValidators: &vals, - NumFullNodes: &fullNodes, + NumValidators: &numVals, + NumFullNodes: &numFullNodesZero, ChainConfig: cfgA, }, }) diff --git a/examples/cosmos/cometmock_test.go b/examples/cosmos/cometmock_test.go index 157f5918b..1bdc4995a 100644 --- a/examples/cosmos/cometmock_test.go +++ b/examples/cosmos/cometmock_test.go @@ -24,6 +24,10 @@ var ( ) func TestCometMock(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode") + } + cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { Name: "juno", diff --git a/examples/cosmos/ethermint_test.go b/examples/cosmos/ethermint_test.go index 2010c58d5..c822c0d31 100644 --- a/examples/cosmos/ethermint_test.go +++ b/examples/cosmos/ethermint_test.go @@ -111,6 +111,8 @@ func TestEthermintChain(t *testing.T) { ExposeAdditionalPorts: []string{"8545/tcp"}, ConfigFileOverrides: map[string]any{"config/app.toml": appTomlOverrides}, }, + NumValidators: &numValsOne, + NumFullNodes: &numFullNodesZero, }, }) @@ -143,7 +145,7 @@ func TestEthermintChain(t *testing.T) { require.Equal(t, "10000000000", balance.String()) // verify access to port exposed via ExposeAdditionalPorts - evmJsonRpcUrl, err := chain.FullNodes[0].GetHostAddress(ctx, "8545/tcp") + evmJsonRpcUrl, err := chain.GetNode().GetHostAddress(ctx, "8545/tcp") require.NoError(t, err) data := []byte(`{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["0x1", null]}`) diff --git a/examples/cosmos/sdk_boundary_test.go b/examples/cosmos/sdk_boundary_test.go index 1d28bea8b..4a66cf01d 100644 --- a/examples/cosmos/sdk_boundary_test.go +++ b/examples/cosmos/sdk_boundary_test.go @@ -33,25 +33,29 @@ func TestSDKBoundaries(t *testing.T) { name: "sdk 45 <-> 50", chainSpecs: []*interchaintest.ChainSpec{ { - Name: "gaia", ChainName: "gaia", Version: "v7.0.3", // sdk 0.45.6 + Name: "gaia", ChainName: "gaia", Version: "v7.0.3", //sdk 0.45.6 + NumValidators: &numValsOne, NumFullNodes: &numFullNodesZero, }, { - Name: "ibc-go-simd", ChainName: "simd-50", Version: "feat-upgrade-sdk-v0.50", // sdk 0.50 alpha + Name: "ibc-go-simd", ChainName: "simd-50", Version: "v8.5.1", // sdk v0.50.10 + NumValidators: &numValsOne, NumFullNodes: &numFullNodesZero, }, }, - relayerVersion: "colin-event-fix", + relayerVersion: rly.DefaultContainerVersion, }, { name: "sdk 47 <-> 50", chainSpecs: []*interchaintest.ChainSpec{ { - Name: "ibc-go-simd", ChainName: "simd-47", Version: "v7.2.0", // sdk 0.47.3 + Name: "ibc-go-simd", ChainName: "simd-47", Version: "v7.2.0", //sdk 0.47.3 + NumValidators: &numValsOne, NumFullNodes: &numFullNodesZero, }, { - Name: "ibc-go-simd", ChainName: "simd-50", Version: "feat-upgrade-sdk-v0.50", // sdk 0.50 alpha + Name: "ibc-go-simd", ChainName: "simd-50", Version: "v8.5.1", // sdk v0.50.10 + NumValidators: &numValsOne, NumFullNodes: &numFullNodesZero, }, }, - relayerVersion: "colin-event-fix", + relayerVersion: rly.DefaultContainerVersion, }, } diff --git a/examples/ibc/ics_test.go b/examples/ibc/ics_test.go index 104f6c387..ca9d59ad5 100644 --- a/examples/ibc/ics_test.go +++ b/examples/ibc/ics_test.go @@ -20,8 +20,6 @@ import ( var ( icsVersions = []string{"v3.1.0", "v3.3.0", "v4.0.0"} - vals = 2 - fNodes = 0 providerChainID = "provider-1" ) @@ -34,13 +32,11 @@ func TestICS(t *testing.T) { icsVersions = []string{ver} } - relayers := []struct { + type relayerTypes struct { rly ibc.RelayerImplementation name string - }{ - {rly: ibc.Hermes, name: "hermes"}, - {rly: ibc.CosmosRly, name: "rly"}, } + relayers := []relayerTypes{{rly: ibc.CosmosRly, name: "rly"}} for _, version := range icsVersions { version := version @@ -63,15 +59,17 @@ func icsTest(t *testing.T, version string, rly ibc.RelayerImplementation) { consumerBechPrefix = "consumer" } + validators := 2 + cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ { Name: "ics-provider", Version: version, - NumValidators: &vals, NumFullNodes: &fNodes, + NumValidators: &validators, NumFullNodes: &numFullNodes, ChainConfig: ibc.ChainConfig{GasAdjustment: 1.5, ChainID: providerChainID, TrustingPeriod: "336h"}, }, { Name: "ics-consumer", Version: version, - NumValidators: &vals, NumFullNodes: &fNodes, + NumValidators: &validators, NumFullNodes: &numFullNodes, ChainConfig: ibc.ChainConfig{GasAdjustment: 1.5, ChainID: "consumer-1", Bech32Prefix: consumerBechPrefix, InterchainSecurityConfig: ibc.ICSConfig{ ConsumerCopyProviderKey: func(i int) bool { return i == 0 @@ -120,6 +118,8 @@ func icsTest(t *testing.T, version string, rly ibc.RelayerImplementation) { // ------------------ ICS Setup ------------------ + require.GreaterOrEqual(t, len(provider.Validators), 2) + // Finish the ICS provider chain initialization. // - Restarts the relayer to connect ics20-1 transfer channel // - Delegates tokens to the provider to update consensus value diff --git a/interchain_test.go b/interchain_test.go index 923ec8b64..b02ea8cd2 100644 --- a/interchain_test.go +++ b/interchain_test.go @@ -30,6 +30,11 @@ import ( "github.com/strangelove-ventures/interchaintest/v8/testutil" ) +var ( + numVals = 1 + numFullNodesZero = 0 +) + func TestInterchain_DuplicateChain_CosmosRly(t *testing.T) { duplicateChainTest(t, ibc.CosmosRly) } @@ -51,26 +56,26 @@ func duplicateChainTest(t *testing.T, relayerImpl ibc.RelayerImplementation) { cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ // Two otherwise identical chains that only differ by ChainID. - {Name: "gaia", ChainName: "g1", Version: "v7.0.1"}, - {Name: "gaia", ChainName: "g2", Version: "v7.0.1"}, + {Name: testutil.TestSimd, ChainName: "c1", Version: testutil.SimdVersion, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, + {Name: testutil.TestSimd, ChainName: "c2", Version: testutil.SimdVersion, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - gaia0, gaia1 := chains[0], chains[1] + chain0, chain1 := chains[0], chains[1] r := interchaintest.NewBuiltinRelayerFactory(relayerImpl, zaptest.NewLogger(t)).Build( t, client, network, ) ic := interchaintest.NewInterchain(). - AddChain(gaia0). - AddChain(gaia1). + AddChain(chain0). + AddChain(chain1). AddRelayer(r, "r"). AddLink(interchaintest.InterchainLink{ - Chain1: gaia0, - Chain2: gaia1, + Chain1: chain0, + Chain2: chain1, Relayer: r, }) @@ -109,26 +114,26 @@ func getRelayerWalletsTest(t *testing.T, relayerImpl ibc.RelayerImplementation) cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ // Two otherwise identical chains that only differ by ChainID. - {Name: "gaia", ChainName: "g1", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, - {Name: "gaia", ChainName: "g2", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-1"}}, + {Name: testutil.TestSimd, ChainName: "c1", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-1"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, + {Name: testutil.TestSimd, ChainName: "c2", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-2"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - gaia0, gaia1 := chains[0], chains[1] + chain0, chain1 := chains[0], chains[1] r := interchaintest.NewBuiltinRelayerFactory(relayerImpl, zaptest.NewLogger(t)).Build( t, client, network, ) ic := interchaintest.NewInterchain(). - AddChain(gaia0). - AddChain(gaia1). + AddChain(chain0). + AddChain(chain1). AddRelayer(r, "r"). AddLink(interchaintest.InterchainLink{ - Chain1: gaia0, - Chain2: gaia1, + Chain1: chain0, + Chain2: chain1, Relayer: r, }) @@ -188,15 +193,15 @@ func TestInterchain_CreateUser(t *testing.T) { cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ // Two otherwise identical chains that only differ by ChainID. - {Name: "gaia", ChainName: "g1", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, + {Name: testutil.TestSimd, ChainName: "c1", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-0"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - gaia0 := chains[0] + chain0 := chains[0] - ic := interchaintest.NewInterchain().AddChain(gaia0) + ic := interchaintest.NewInterchain().AddChain(chain0) defer ic.Close() rep := testreporter.NewNopReporter() @@ -230,26 +235,26 @@ func TestInterchain_CreateUser(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, mnemonic) - user, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, keyName, mnemonic, initBal, gaia0) + user, err := interchaintest.GetAndFundTestUserWithMnemonic(ctx, keyName, mnemonic, initBal, chain0) require.NoError(t, err) - require.NoError(t, testutil.WaitForBlocks(ctx, 2, gaia0)) + require.NoError(t, testutil.WaitForBlocks(ctx, 2, chain0)) require.NotEmpty(t, user.Address()) require.NotEmpty(t, user.KeyName()) - actualBalance, err := gaia0.GetBalance(ctx, user.FormattedAddress(), gaia0.Config().Denom) + actualBalance, err := chain0.GetBalance(ctx, user.FormattedAddress(), chain0.Config().Denom) require.NoError(t, err) require.True(t, actualBalance.Equal(initBal)) }) t.Run("without mnemonic", func(t *testing.T) { keyName := "regular-user-name" - users := interchaintest.GetAndFundTestUsers(t, ctx, keyName, initBal, gaia0) - require.NoError(t, testutil.WaitForBlocks(ctx, 2, gaia0)) + users := interchaintest.GetAndFundTestUsers(t, ctx, keyName, initBal, chain0) + require.NoError(t, testutil.WaitForBlocks(ctx, 2, chain0)) require.Len(t, users, 1) require.NotEmpty(t, users[0].Address()) require.NotEmpty(t, users[0].KeyName()) - actualBalance, err := gaia0.GetBalance(ctx, users[0].FormattedAddress(), gaia0.Config().Denom) + actualBalance, err := chain0.GetBalance(ctx, users[0].FormattedAddress(), chain0.Config().Denom) require.NoError(t, err) require.True(t, actualBalance.Equal(initBal)) }) @@ -301,9 +306,9 @@ func TestInterchain_ConcurrentRelayerOps(t *testing.T) { chainSpecs := make([]*interchaintest.ChainSpec, chains) for i := 0; i < chains; i++ { chainSpecs[i] = &interchaintest.ChainSpec{ - Name: "gaia", + Name: testutil.TestSimd, ChainName: fmt.Sprintf("g%d", i+1), - Version: "v7.0.1", + Version: testutil.SimdVersion, NumValidators: &numValidators, NumFullNodes: &numFullNodes, ChainConfig: ibc.ChainConfig{ @@ -365,14 +370,14 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ // Two otherwise identical chains that only differ by ChainID. - {Name: "gaia", ChainName: "g1", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, - {Name: "gaia", ChainName: "g2", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-1"}}, + {Name: testutil.TestSimd, ChainName: "c1", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-1"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, + {Name: testutil.TestSimd, ChainName: "c2", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-2"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - gaia0, gaia1 := chains[0], chains[1] + chain0, chain1 := chains[0], chains[1] r := interchaintest.NewBuiltinRelayerFactory(relayerImpl, zaptest.NewLogger(t)).Build( t, client, network, @@ -380,12 +385,12 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat pathName := "p" ic := interchaintest.NewInterchain(). - AddChain(gaia0). - AddChain(gaia1). + AddChain(chain0). + AddChain(chain1). AddRelayer(r, "r"). AddLink(interchaintest.InterchainLink{ - Chain1: gaia0, - Chain2: gaia1, + Chain1: chain0, + Chain2: chain1, Relayer: r, Path: pathName, }) @@ -400,7 +405,7 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat NetworkID: network, })) - testUser := interchaintest.GetAndFundTestUsers(t, ctx, "gaia-user-1", math.NewInt(10_000_000), gaia0)[0] + testUser := interchaintest.GetAndFundTestUsers(t, ctx, "chain-user-1", math.NewInt(10_000_000), chain0)[0] sendAmount := math.NewInt(10_000) @@ -409,17 +414,20 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat }) t.Run("broadcast success", func(t *testing.T) { - b := cosmos.NewBroadcaster(t, gaia0.(*cosmos.CosmosChain)) - transferAmount := sdk.Coin{Denom: gaia0.Config().Denom, Amount: sendAmount} + b := cosmos.NewBroadcaster(t, chain0.(*cosmos.CosmosChain)) + transferAmount := sdk.Coin{Denom: chain0.Config().Denom, Amount: sendAmount} memo := "" + h, err := chain0.Height(ctx) + require.NoError(t, err) + msg := transfertypes.NewMsgTransfer( "transfer", "channel-0", transferAmount, testUser.FormattedAddress(), - testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(gaia1.Config().Bech32Prefix), - clienttypes.NewHeight(1, 1000), + testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(chain1.Config().Bech32Prefix), + clienttypes.NewHeight(2, uint64(h)+100), 0, memo, ) @@ -429,12 +437,12 @@ func broadcastTxCosmosChainTest(t *testing.T, relayerImpl ibc.RelayerImplementat }) t.Run("transfer success", func(t *testing.T) { - require.NoError(t, testutil.WaitForBlocks(ctx, 5, gaia0, gaia1)) + require.NoError(t, testutil.WaitForBlocks(ctx, 5, chain0, chain1)) - srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", gaia0.Config().Denom)) + srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", chain0.Config().Denom)) dstIbcDenom := srcDenomTrace.IBCDenom() - dstFinalBalance, err := gaia1.GetBalance(ctx, testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(gaia1.Config().Bech32Prefix), dstIbcDenom) + dstFinalBalance, err := chain1.GetBalance(ctx, testUser.(*cosmos.CosmosWallet).FormattedAddressWithPrefix(chain1.Config().Bech32Prefix), dstIbcDenom) require.NoError(t, err, "failed to get balance from dest chain") require.True(t, dstFinalBalance.Equal(sendAmount)) }) @@ -452,15 +460,15 @@ func TestInterchain_OmitGitSHA(t *testing.T) { client, network := interchaintest.DockerSetup(t) cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ - {Name: "gaia", Version: "v7.0.1"}, + {Name: testutil.TestSimd, Version: testutil.SimdVersion, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - gaia := chains[0] + chain := chains[0] ic := interchaintest.NewInterchain(). - AddChain(gaia) + AddChain(chain) rep := testreporter.NewNopReporter() eRep := rep.RelayerExecReporter(t) @@ -480,7 +488,7 @@ func TestInterchain_OmitGitSHA(t *testing.T) { func TestInterchain_ConflictRejection(t *testing.T) { t.Run("duplicate chain", func(t *testing.T) { cf := interchaintest.NewBuiltinChainFactory(zap.NewNop(), []*interchaintest.ChainSpec{ - {Name: "gaia", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, + {Name: testutil.TestSimd, Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-0"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) @@ -496,14 +504,14 @@ func TestInterchain_ConflictRejection(t *testing.T) { t.Run("chain name", func(t *testing.T) { cf := interchaintest.NewBuiltinChainFactory(zap.NewNop(), []*interchaintest.ChainSpec{ // Different ChainID, but explicit ChainName used twice. - {Name: "gaia", ChainName: "g", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, - {Name: "gaia", ChainName: "g", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-1"}}, + {Name: testutil.TestSimd, ChainName: "c", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-0"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, + {Name: testutil.TestSimd, ChainName: "c", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-1"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - require.PanicsWithError(t, "a chain with name g already exists", func() { + require.PanicsWithError(t, "a chain with name c already exists", func() { _ = interchaintest.NewInterchain().AddChain(chains[0]).AddChain(chains[1]) }) }) @@ -511,14 +519,14 @@ func TestInterchain_ConflictRejection(t *testing.T) { t.Run("chain ID", func(t *testing.T) { cf := interchaintest.NewBuiltinChainFactory(zap.NewNop(), []*interchaintest.ChainSpec{ // Valid ChainName but duplicate ChainID. - {Name: "gaia", ChainName: "g1", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, - {Name: "gaia", ChainName: "g2", Version: "v7.0.1", ChainConfig: ibc.ChainConfig{ChainID: "cosmoshub-0"}}, + {Name: testutil.TestSimd, ChainName: "c1", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-0"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, + {Name: testutil.TestSimd, ChainName: "c2", Version: testutil.SimdVersion, ChainConfig: ibc.ChainConfig{ChainID: "chain-0"}, NumValidators: &numVals, NumFullNodes: &numFullNodesZero}, }) chains, err := cf.Chains(t.Name()) require.NoError(t, err) - require.PanicsWithError(t, "a chain with ID cosmoshub-0 already exists", func() { + require.PanicsWithError(t, "a chain with ID chain-0 already exists", func() { _ = interchaintest.NewInterchain().AddChain(chains[0]).AddChain(chains[1]) }) }) diff --git a/testutil/doc.go b/testutil/doc.go index f6542ace6..306af54ea 100644 --- a/testutil/doc.go +++ b/testutil/doc.go @@ -1,2 +1,7 @@ // Package testutil includes convenience functions and types to help with testing package testutil + +const ( + TestSimd = "ibc-go-simd" + SimdVersion = "v8.5.1" +)