Skip to content
Merged
39 changes: 36 additions & 3 deletions .github/workflows/interchaintest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build_images:
name: Build archway images 🛠️
name: Build archway images
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
retention_days: 3

run_chain_upgrade_test:
name: Chain upgrade test 🏆
name: Chain upgrade test
needs: [build_images]
runs-on: ubuntu-latest

Expand Down Expand Up @@ -104,4 +104,37 @@ jobs:
- name: Run chain upgrade test
run: |
cd interchaintest
go test -v -race -run TestChainUpgrade
go test -v -race -run TestChainUpgrade

ibc_conformance_tests:
name: Gaia <> Archway Conformance
needs: [build_images]
runs-on: ubuntu-latest

steps:
- name: Checkout archway-network/archway/interchaintest
uses: actions/checkout@v3
with:
fetch-depth: 0
sparse-checkout: interchaintest

- name: Setup up Golang
uses: actions/setup-go@v4
with:
go-version-file: 'interchaintest/go.mod'

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Download current image
uses: actions/download-artifact@v3
with:
name: action_image_artifact_archway_local

- name: Load current image
run: docker load --input archway_local

- name: Run chain conformance test
run: |
cd interchaintest
go test -v -race -run TestGaiaConformance
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ Contains all the PRs that improved the code without changing the behaviours.

## [Unreleased]

### Added
### Added

- [#431](https://github.com/archway-network/archway/pull/431) - Added gh workflow to run IBC conformance tests on PRs

### Changed

Expand Down
69 changes: 39 additions & 30 deletions interchaintest/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
# Interchain Test

## Chain upgrade test
To run the interchain tests, we need to use Heighliner.

To run the chain upgrade test locally:
To install Heighliner

```sh
git clone https://github.com/strangelove-ventures/heighliner.git
cd heighliner
go install
```

1. Install Heighliner

```sh
git clone https://github.com/strangelove-ventures/heighliner.git
cd heighliner
go install
```

2. Build the current branch docker image

```sh
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref <local_branch_name> --tag local
docker image tag acrechain:local archway:local # There is an issue with heighliner where it wrongly names the docker image
docker rmi acrechain:local
```

3. Build the last release docker image

```sh
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref v3.0.0 --tag local
docker image tag acrechain:3.0.0archway:3.0.0
docker rmi acrechain:3.0.0
```
Using Heighliner, build a docker image of your local branch

```sh
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref <local_branch_name> --tag local
docker image tag acrechain:local archway:local # There is an issue with heighliner where it wrongly names the docker image
docker rmi acrechain:local
```

## IBC conformance test

To run the IBC conformance test locally go to Archway repo root and

```sh
cd interchaintest
go test -v -race -run TestGaiaConformance
go test -v -race -run TestOsmosisConformance
Comment thread
spoo-bar marked this conversation as resolved.
Outdated
```

## Chain upgrade test

To run the chain upgrade test locally, first build the last release docker image. The version should match the value of `initialVersion` in [setup.go](./setup.go)

```sh
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref v3.0.0 --tag local
docker image tag acrechain:3.0.0archway:3.0.0
Comment thread
spoo-bar marked this conversation as resolved.
Outdated
docker rmi acrechain:3.0.0
```

4. Now go to Archway repo root and
Now go to Archway repo root and run

```sh
cd interchaintest
go test -v -race -run TestChainUpgrade
```
```sh
cd interchaintest
go test -v -race -run TestChainUpgrade
```
9 changes: 2 additions & 7 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,9 @@ func fundChainUser(t *testing.T, ctx context.Context, archwayChain *cosmos.Cosmo

func startChain(t *testing.T) (*cosmos.CosmosChain, *client.Client, context.Context) {
numOfVals := 1
archwayChainSpec := GetArchwaySpec(initialVersion, numOfVals)
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
Name: chainName,
ChainName: "archway-1",
Version: initialVersion,
ChainConfig: archwayConfig,
NumValidators: &numOfVals,
},
archwayChainSpec,
})
chains, err := cf.Chains(t.Name())
require.NoError(t, err)
Expand Down
85 changes: 85 additions & 0 deletions interchaintest/ibc_conformance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package interchaintest

import (
"context"
"testing"

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

func TestGaiaConformance(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}

gaiaChainSpec := &interchaintest.ChainSpec{
Name: "gaia",
ChainName: "gaia",
Version: "latest",
}
runConformanceTest(t, gaiaChainSpec)
}

func runConformanceTest(t *testing.T, gaiaChainSpec *interchaintest.ChainSpec) {
numOfVals := 1
archwayChainSpec := GetArchwaySpec("local", numOfVals)

// Setup the chains
chainFactory := interchaintest.NewBuiltinChainFactory(
zaptest.NewLogger(t),
[]*interchaintest.ChainSpec{
archwayChainSpec,
gaiaChainSpec,
})
chains, err := chainFactory.Chains(t.Name())
require.NoError(t, err)
archwayChain, counterpartyChain := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain)

// Setup the relayer
const (
path = "ibc-upgrade-test-path"
relayerName = "relayer"
)
relayerFactory := interchaintest.NewBuiltinRelayerFactory(
ibc.CosmosRly,
zaptest.NewLogger(t),
relayer.StartupFlags("-b", "100"),
)
client, network := interchaintest.DockerSetup(t)
relayer := relayerFactory.Build(t, client, network)

// Create the IBC network with the chains and relayer
ic := interchaintest.NewInterchain().
AddChain(archwayChain).
AddChain(counterpartyChain).
AddRelayer(relayer, "relayer").
AddLink(interchaintest.InterchainLink{
Chain1: archwayChain,
Chain2: counterpartyChain,
Relayer: relayer,
Path: path,
})
rep := testreporter.NewNopReporter()
ctx := context.Background()

// Starts all the components of the IBC network
require.NoError(t, ic.Build(ctx, rep.RelayerExecReporter(t), interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: false,
}))
t.Cleanup(func() {
_ = ic.Close()
})

// Perform the conformance test between the two chains
conformance.TestChainPair(t, ctx, client, network, archwayChain, counterpartyChain, relayerFactory, rep, relayer, path)
}
43 changes: 30 additions & 13 deletions interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package interchaintest
import (
"fmt"

"github.com/strangelove-ventures/interchaintest/v4"
"github.com/strangelove-ventures/interchaintest/v4/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v4/ibc"
)
Expand All @@ -14,39 +15,55 @@ const (
)

const (
votingPeriod = "10s" // Reducing voting period for testing
maxDepositPeriod = "10s" // Reducing max deposit period for testing
)
coinType = "118"
chainType = "cosmos"
ibcTrustingPeriod = "112h"

var (
coinType = "118"
denom = "aarch"
denom = "aarch"
bech32Prefix = "archway"
)

dockerImage = ibc.DockerImage{
func GetArchwaySpec(dockerImageVersion string, numOfVals int) *interchaintest.ChainSpec {
chainConfig := getDefaultChainConfig()
chainConfig.Images = []ibc.DockerImage{{
Repository: chainName,
Version: initialVersion,
Version: dockerImageVersion,
UidGid: "1025:1025",
}}
archwayChainSpec := &interchaintest.ChainSpec{
Name: chainName,
ChainName: "archway-1",
Version: dockerImageVersion,
ChainConfig: chainConfig,
NumValidators: &numOfVals,
}
return archwayChainSpec
}

archwayConfig = ibc.ChainConfig{
Type: "cosmos",
func getDefaultChainConfig() ibc.ChainConfig {
return ibc.ChainConfig{
Type: chainType,
Name: chainName,
ChainID: "archway-local",
Images: []ibc.DockerImage{dockerImage},
Bin: "archwayd",
Bech32Prefix: "archway",
Bech32Prefix: bech32Prefix,
Denom: denom,
CoinType: coinType,
GasPrices: fmt.Sprintf("0%s", denom),
GasAdjustment: 2.0,
TrustingPeriod: "112h",
TrustingPeriod: ibcTrustingPeriod,
NoHostMount: false,
SkipGenTx: false,
PreGenesis: nil,
ModifyGenesis: cosmos.ModifyGenesis(getTestGenesis()),
ConfigFileOverrides: nil,
UsingNewGenesisCommand: false,
}
}

const (
votingPeriod = "10s" // Reducing voting period for testing
maxDepositPeriod = "10s" // Reducing max deposit period for testing
)

func getTestGenesis() []cosmos.GenesisKV {
Expand Down