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

test: Add IBC conformance test and enable as gh workflow #431

Merged
merged 11 commits into from
Sep 14, 2023
47 changes: 38 additions & 9 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 @@ -39,9 +39,7 @@ jobs:

- name: Build current image
run: |
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref ${{ github.head_ref }} --tag local
docker image tag acrechain:local archway:local
docker rmi acrechain:local
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref ${{ github.head_ref }} --chain archway --tag local

- name: Upload current image
uses: ishworkh/container-image-artifact-upload@v1.0.0
Expand All @@ -51,9 +49,7 @@ jobs:

- name: Build ${{ steps.lastrelease.outputs.tag }} image
run: |
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref ${{ steps.lastrelease.outputs.tag }} --tag ${{ steps.lastrelease.outputs.tag }}
docker image tag acrechain:${{ steps.lastrelease.outputs.tag }} archway:${{ steps.lastrelease.outputs.tag }}
docker rmi acrechain:${{ steps.lastrelease.outputs.tag }}
heighliner build --org archway-network --repo archway --dockerfile cosmos --build-target "make build" --build-env "BUILD_TAGS=muslc" --binaries "build/archwayd" --git-ref ${{ steps.lastrelease.outputs.tag }} --chain archway --tag ${{ steps.lastrelease.outputs.tag }}

- name: Upload ${{ steps.lastrelease.outputs.tag }} image
uses: ishworkh/container-image-artifact-upload@v1.0.0
Expand All @@ -62,7 +58,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 +100,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

- [#439](https://github.com/archway-network/archway/pull/439) - Adding containerized localnet
- [#445](https://github.com/archway-network/archway/pull/445) - Adding Archway logo and version number to upgrade logs
Expand Down
64 changes: 34 additions & 30 deletions interchaintest/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# 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> --chain archway --tag 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
```

## 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 --chain archway --tag local
```

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, startingVersion string) (*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: startingVersion,
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
Loading