Skip to content
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .github/workflows/interchaintest-e2e.yml
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
Comment on lines +48 to +51

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

go clean -cache negates the benefit of Go build caching.

actions/setup-go with cache: true restores cached build artifacts, but immediately running go clean -cache wipes 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 on go.sum changes). Otherwise, disable caching entirely to avoid the wasted restore time.

Proposed fix: remove the clean step
-      # Use go clean instead of manual deletion to avoid permission errors
-      - name: Cleanup Go caches
-        run: |
-          go clean -cache

Also applies to: 107-110

🤖 Prompt for AI Agents
In @.github/workflows/interchaintest-e2e.yml around lines 48 - 51, The "Cleanup
Go caches" step currently runs "go clean -cache", which removes restored build
caches and defeats actions/setup-go cache benefits; remove the step(s) that run
"go clean -cache" (the step named "Cleanup Go caches") at both occurrences so
the CI relies on setup-go's caching behavior (or alternatively disable caching
entirely if you prefer to avoid stale cache issues).


- 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 }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## UNRELEASED

## Added
- Added interchain testing

## Removed

- Stripped out wasmd precompile
Expand Down
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,38 @@ docker-build-hermes:

docker-build-all: docker-build-debug docker-build-hermes

###############################################################################
### Interchain Tests ###
###############################################################################

ictest-basic:
@echo "Running basic interchain e2e test"
@cd tests/interchaintest && go test -race -v -run TestBasicChain .

ictest-ibc:
@echo "Running IBC interchain e2e test"
@cd tests/interchaintest && go test -race -v -run TestIBCBasic .

ictest-wasm:
@echo "Running cosmwasm interchain e2e test"
@cd tests/interchaintest && go test -race -v -run TestCosmWasmIntegration .

ictest-packetforward:
@echo "Running packet forward middleware interchain e2e test"
@cd tests/interchaintest && go test -race -v -run TestPacketForwardMiddleware .

ictest-tokenfactory:
@echo "Running token factory interchain e2e test"
@cd tests/interchaintest && go test -race -v -run TestTokenFactory .

ictest-ratelimit:
@echo "Running rate limit interchain e2e test"
@cd tests/interchaintest && go test -race -v -run TestIBCRateLimit .

ictest-all: ictest-basic ictest-ibc ictest-wasm ictest-packetforward ictest-tokenfactory ictest-ratelimit

.PHONY: ictest-basic ictest-ibc ictest-wasm ictest-packetforward ictest-tokenfactory ictest-ratelimit ictest-all

###############################################################################
### Linting ###
###############################################################################
Expand Down
60 changes: 60 additions & 0 deletions tests/interchaintest/basic_test.go
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.
71 changes: 71 additions & 0 deletions tests/interchaintest/cosmwasm_test.go
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)
Comment thread
Thaleszh marked this conversation as resolved.

return contractAddr
}
61 changes: 61 additions & 0 deletions tests/interchaintest/debug_test.go
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")
})
}
Loading
Loading