Skip to content
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

InterchainTest for v3 #243

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
77 changes: 77 additions & 0 deletions .github/workflows/interchaintest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Interchain Tests

on:
pull_request:
push:
branches:
- release/v3.0.x

jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build_push_image
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: .
push: true
platforms: linux/amd64
tags: |
ghcr.io/white-whale-defi-platform/migaloo-chain-ictest:latest
test-start-cosmos-chain:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: checkout code
uses: actions/checkout@v3

- run: make ictest-start-cosmos
env:
BRANCH_CI: 'latest'
test-ibc-transfer:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: checkout code
uses: actions/checkout@v3

- run: make ictest-ibc
env:
BRANCH_CI: 'latest'
test-upgrade-chain:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: checkout code
uses: actions/checkout@v3

- run: make ictest-upgrade
env:
BRANCH_CI: 'latest'
6 changes: 3 additions & 3 deletions .github/workflows/push-docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/White-Whale-Defi-Platform/migaloo-chain:${{ env.MAJOR_VERSION }}
ghcr.io/White-Whale-Defi-Platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/White-Whale-Defi-Platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
ghcr.io/white-whale-defi-platform/migaloo-chain:${{ env.MAJOR_VERSION }}
ghcr.io/white-whale-defi-platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
ghcr.io/white-whale-defi-platform/migaloo-chain:${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}.${{ env.PATCH_VERSION }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bin
.vscode
.ash_history
go.work.sum
go.work
*/.DS_Store


22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,25 @@ install: go.sum

build:
go build $(BUILD_FLAGS) -o bin/migalood ./cmd/migalood

docker-build-debug:
@DOCKER_BUILDKIT=1 docker build -t migaloo:debug -f Dockerfile .
###############################################################################
### Interchain test ###
###############################################################################

# Executes start chain tests via interchaintest
ictest-start-cosmos:
cd interchaintest && go test -race -v -run TestStartMigaloo .

ictest-ibc:
cd interchaintest && go test -race -v -run TestMigalooGaiaIBCTransfer .

# Executes Basic Upgrade Chain tests via interchaintest
ictest-upgrade:
cd interchaintest && go test -timeout=25m -race -v -run TestMigalooUpgrade .

# Executes all tests via interchaintest after compling a local image as migaloo:local
ictest-all: ictest-start-cosmos ictest-ibc ictest-upgrade

.PHONY: ictest-start-cosmos ictest-ibc ictest-upgrade ictest-all
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ func (app *MigalooApp) setupUpgradeHandlers(cfg module.Configurator) {
}

for _, upgrade := range Upgrades {
upgrade := upgrade
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
}
Expand Down
6 changes: 6 additions & 0 deletions go.work.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
go 1.20

use (
.
./interchaintest
)
66 changes: 66 additions & 0 deletions interchaintest/chain_start_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package interchaintest

import (
"context"
"testing"

"github.com/strangelove-ventures/interchaintest/v5"
"github.com/strangelove-ventures/interchaintest/v5/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v5/testreporter"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)

// TestStartMigaloo is a basic test to assert that spinning up a Migaloo network with 1 validator works properly.
func TestStartMigaloo(t *testing.T) {
if testing.Short() {
t.Skip()
}

t.Parallel()

ctx := context.Background()

// Create chain factory with Migaloo
numVals := 1
numFullNodes := 1

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: "migaloo",
ChainConfig: migalooConfig,
NumValidators: &numVals,
NumFullNodes: &numFullNodes,
},
})

// Get chains from the chain factory
chains, err := cf.Chains(t.Name())
require.NoError(t, err)

migaloo := chains[0].(*cosmos.CosmosChain)

// Relayer Factory
client, network := interchaintest.DockerSetup(t)

// Create a new Interchain object which describes the chains, relayers, and IBC connections we want to use
ic := interchaintest.NewInterchain().AddChain(migaloo)

rep := testreporter.NewNopReporter()
eRep := rep.RelayerExecReporter(t)

err = ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: true,

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: interchaintest.DefaultBlockDatabaseFilepath(),
})
require.NoError(t, err)

t.Cleanup(func() {
_ = ic.Close()
})
}
Loading
Loading