-
Notifications
You must be signed in to change notification settings - Fork 124
test: add interchain tests #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ad597af
chore: import 'useful' tests
633f49e
fix: correct compile issues
d241963
chore: ditch bad tests
cc9d1b3
chore: bring over interchain tests and swap kiichain to v7
899093b
docs: changelog interchain testing
91cc429
fix: remove deprecated fallback native price
ba5da91
fix: bump go version on pipeline action
4c7cc73
fix: use correct config naming
b29a8a5
fix: add missing denom info on interchain test setup
518366f
fix: setup chain id correctly
62dad3b
fix: use denom metadata as it should on genesis kv
c482708
fix: use variables for the bank denom metadata
e19a0d6
fix: use math.int when checking equals
ca923f8
fix: correct denom units
105aa0e
fix: transform denom metadata into interface
c59b182
fix: use same gas prices as e2e tests
4bc88d8
fix: bump min gas price to acceptable range
e80d413
chore: clean uneeded code
8591ea4
fix: bump amount received for users
f2d7c3e
fix: lower gas adjustment
257505b
fix: fund faucet
200bc63
fix: fund faucet for chains
96b1c41
fix: remove empty function
09b8e0c
fix: ensure gas adjustment is correct
094264d
fix: correct funds passed on cosmwasm
3062a97
fix: intantiate second chain spec correctly
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| name: Interchain E2E Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - master | ||
| - 'feature/**' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - master | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| env: | ||
| GO_VERSION: 1.24 | ||
| TAR_PATH: /tmp/docker-image.tar | ||
| IMAGE_NAME: docker-image | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| build-docker: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - id: go-cache-paths | ||
| run: | | ||
| echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT | ||
| echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Go ${{ env.GO_VERSION }} | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} | ||
| cache: true | ||
| cache-dependency-path: | | ||
| go.sum | ||
| tests/interchaintest/go.sum | ||
|
|
||
| # Use go clean instead of manual deletion to avoid permission errors | ||
| - name: Cleanup Go caches | ||
| run: | | ||
| go clean -cache | ||
|
|
||
| - name: Download Go Dependencies | ||
| run: | | ||
| go mod download | ||
| cd tests/interchaintest && go mod download | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build and export | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| tags: kiichain:local | ||
| outputs: type=docker,dest=${{ env.TAR_PATH }} | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ env.IMAGE_NAME }} | ||
| path: ${{ env.TAR_PATH }} | ||
|
|
||
| interchain-tests: | ||
| needs: build-docker | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| # names of `make` commands to run tests | ||
| test: | ||
| - "ictest-basic" | ||
| - "ictest-ibc" | ||
| - "ictest-wasm" | ||
| - "ictest-packetforward" | ||
| - "ictest-tokenfactory" | ||
| - "ictest-ratelimit" | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - id: go-cache-paths | ||
| run: | | ||
| echo "go-build=$(go env GOCACHE)" >> $GITHUB_OUTPUT | ||
| echo "go-mod=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: checkout chain | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go ${{ env.GO_VERSION }} | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: ${{ env.GO_VERSION }} | ||
| cache: true | ||
| cache-dependency-path: | | ||
| go.sum | ||
| tests/interchaintest/go.sum | ||
|
|
||
| # Use go clean instead of manual deletion to avoid permission errors | ||
| - name: Cleanup Go caches | ||
| run: | | ||
| go clean -cache | ||
|
|
||
| - name: Download Tarball Artifact | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: ${{ env.IMAGE_NAME }} | ||
| path: /tmp | ||
|
|
||
| - name: Load Docker Image | ||
| run: | | ||
| docker image load -i ${{ env.TAR_PATH }} | ||
| docker image ls -a | ||
|
|
||
| - name: Run Test | ||
| run: make ${{ matrix.test }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,9 @@ | |
|
|
||
| ## UNRELEASED | ||
|
|
||
| ## Added | ||
| - Added interchain testing | ||
|
|
||
| ## Removed | ||
|
|
||
| - Stripped out wasmd precompile | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| package interchaintest | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
| "time" | ||
|
|
||
| sdkmath "cosmossdk.io/math" | ||
| "github.com/cosmos/interchaintest/v10" | ||
| "github.com/cosmos/interchaintest/v10/chain/cosmos" | ||
| "github.com/cosmos/interchaintest/v10/testreporter" | ||
| "github.com/stretchr/testify/require" | ||
| "go.uber.org/zap/zaptest" | ||
| ) | ||
|
|
||
| func TestBasicChain(t *testing.T) { | ||
| ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) | ||
| defer cancel() | ||
| rep := testreporter.NewNopReporter() | ||
| eRep := rep.RelayerExecReporter(t) | ||
| client, network := interchaintest.DockerSetup(t) | ||
|
|
||
| cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ | ||
| &DefaultChainSpec, | ||
| }) | ||
|
|
||
| chains, err := cf.Chains(t.Name()) | ||
| require.NoError(t, err) | ||
|
|
||
| chain := chains[0].(*cosmos.CosmosChain) | ||
|
|
||
| // Setup Interchain | ||
| ic := interchaintest.NewInterchain(). | ||
| AddChain(chain) | ||
|
|
||
| require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{ | ||
| TestName: t.Name(), | ||
| Client: client, | ||
| NetworkID: network, | ||
| SkipPathCreation: false, | ||
| })) | ||
| t.Cleanup(func() { | ||
| _ = ic.Close() | ||
| }) | ||
|
|
||
| // Use amount that faucet can afford with zero gas fees | ||
| amt := sdkmath.NewInt(50_000_000_000_000) // 50T akii | ||
| users := interchaintest.GetAndFundTestUsers(t, ctx, "default", amt, | ||
| chain, | ||
| ) | ||
| user := users[0] | ||
|
|
||
| t.Run("validate funding", func(t *testing.T) { | ||
| t.Logf("Querying balance for user: %s", user.FormattedAddress()) | ||
| bal, err := chain.BankQueryBalance(ctx, user.FormattedAddress(), chain.Config().Denom) | ||
| require.NoError(t, err) | ||
| t.Logf("Expected: %s, Got: %s", amt.String(), bal.String()) | ||
| require.EqualValues(t, amt, bal) | ||
| }) | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| package interchaintest | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/cosmos/interchaintest/v10" | ||
| "github.com/cosmos/interchaintest/v10/chain/cosmos" | ||
| "github.com/cosmos/interchaintest/v10/ibc" | ||
| "github.com/cosmos/interchaintest/v10/testreporter" | ||
| "github.com/stretchr/testify/require" | ||
| "go.uber.org/zap/zaptest" | ||
| ) | ||
|
|
||
| type GetCountResponse struct { | ||
| // {"data":{"count":0}} | ||
| Data *GetCountObj `json:"data"` | ||
| } | ||
|
|
||
| type GetCountObj struct { | ||
| Count int64 `json:"count"` | ||
| } | ||
|
|
||
| func TestCosmWasmIntegration(t *testing.T) { | ||
| t.Parallel() | ||
| ctx := context.Background() | ||
| rep := testreporter.NewNopReporter() | ||
| eRep := rep.RelayerExecReporter(t) | ||
| client, network := interchaintest.DockerSetup(t) | ||
|
|
||
| cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ | ||
| &DefaultChainSpec, | ||
| }) | ||
|
|
||
| chains, err := cf.Chains(t.Name()) | ||
| require.NoError(t, err) | ||
|
|
||
| chain := chains[0].(*cosmos.CosmosChain) | ||
|
|
||
| // Setup Interchain | ||
| ic := interchaintest.NewInterchain(). | ||
| AddChain(chain) | ||
|
|
||
| require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{ | ||
| TestName: t.Name(), | ||
| Client: client, | ||
| NetworkID: network, | ||
| SkipPathCreation: false, | ||
| })) | ||
| t.Cleanup(func() { | ||
| _ = ic.Close() | ||
| }) | ||
|
|
||
| users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), GenesisFundsAmount, chain) | ||
| user := users[0] | ||
|
|
||
| StdExecute(t, ctx, chain, user) | ||
| } | ||
|
|
||
| func StdExecute(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet) (contractAddr string) { | ||
| _, contractAddr = SetupContract(t, ctx, chain, user.KeyName(), "contracts/cw_template.wasm", `{"count":0}`) | ||
| chain.ExecuteContract(ctx, user.KeyName(), contractAddr, `{"increment":{}}`, "--fees", "10000"+chain.Config().Denom) | ||
|
|
||
| var res GetCountResponse | ||
| err := SmartQueryString(t, ctx, chain, contractAddr, `{"get_count":{}}`, &res) | ||
| require.NoError(t, err) | ||
|
|
||
| require.Equal(t, int64(1), res.Data.Count) | ||
|
Thaleszh marked this conversation as resolved.
|
||
|
|
||
| return contractAddr | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| package interchaintest | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/cosmos/interchaintest/v10" | ||
| "github.com/cosmos/interchaintest/v10/chain/cosmos" | ||
| "github.com/cosmos/interchaintest/v10/testreporter" | ||
| "github.com/stretchr/testify/require" | ||
| "go.uber.org/zap/zaptest" | ||
| ) | ||
|
|
||
| func TestDebugChain(t *testing.T) { | ||
| ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute) | ||
| defer cancel() | ||
| rep := testreporter.NewNopReporter() | ||
| eRep := rep.RelayerExecReporter(t) | ||
| client, network := interchaintest.DockerSetup(t) | ||
|
|
||
| cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{ | ||
| &DefaultChainSpec, | ||
| }) | ||
|
|
||
| chains, err := cf.Chains(t.Name()) | ||
| require.NoError(t, err) | ||
|
|
||
| chain := chains[0].(*cosmos.CosmosChain) | ||
|
|
||
| // Setup Interchain | ||
| ic := interchaintest.NewInterchain(). | ||
| AddChain(chain) | ||
|
|
||
| require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{ | ||
| TestName: t.Name(), | ||
| Client: client, | ||
| NetworkID: network, | ||
| SkipPathCreation: false, | ||
| })) | ||
| t.Cleanup(func() { | ||
| _ = ic.Close() | ||
| }) | ||
|
|
||
| // Wait for chain to start properly | ||
| time.Sleep(10 * time.Second) | ||
|
|
||
| // Test basic functionality - just check if we can query chain info | ||
| t.Run("query chain info", func(t *testing.T) { | ||
| t.Logf("Chain ID: %s", chain.Config().ChainID) | ||
| t.Logf("RPC Address: %s", chain.GetRPCAddress()) | ||
|
|
||
| // Simple query that should work | ||
| height, err := chain.Height(ctx) | ||
| require.NoError(t, err) | ||
| t.Logf("Current height: %d", height) | ||
| require.Greater(t, height, uint64(0)) | ||
|
|
||
| t.Logf("Basic chain queries are working correctly") | ||
| }) | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go clean -cachenegates the benefit of Go build caching.actions/setup-gowithcache: truerestores cached build artifacts, but immediately runninggo clean -cachewipes them. This forces a full rebuild every time, defeating the purpose of caching.If the intent is to avoid stale cache issues, consider removing the cache clean step and relying on
setup-go's cache key (which is based ongo.sumchanges). Otherwise, disable caching entirely to avoid the wasted restore time.Proposed fix: remove the clean step
Also applies to: 107-110
🤖 Prompt for AI Agents