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

Add Interchaintest in CI #189

Merged
merged 12 commits into from
Jan 30, 2024
Merged
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
94 changes: 94 additions & 0 deletions .github/workflows/interchaintest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Interchaintest

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, labeled]

env:
GO_VERSION: "1.21.0"
GOPRIVATE: github.com/sedaprotocol/vrf-go
GITHUB_TOKEN: ${{ secrets.PAT }}
TAR_PATH: /tmp/seda-docker-image.tar
IMAGE_NAME: seda-chaind-e2e
SEDA_EXPONENT: ${{ secrets.SEDA_EXPONENT_ICT || 18 }}

permissions:
contents: read
repository-projects: read
packages: read

concurrency:
group: ci-${{ github.ref }}-interchaintest
cancel-in-progress: true

jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: interchaintest/go.sum

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and export
uses: docker/build-push-action@v5
with:
context: .
file: ./dockerfiles/Dockerfile.e2e
tags: seda-chaind-e2e
build-args: SEDA_EXPONENT=${{ env.SEDA_EXPONENT }}
outputs: type=docker,dest=${{ env.TAR_PATH }}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.IMAGE_NAME }}
path: ${{ env.TAR_PATH }}

interchaintest:
needs: build-docker-image
runs-on: ubuntu-latest
strategy:
matrix:
test:
- "ictest-sdk-commands"
- "ictest-sdk-boundaries"
- "ictest-chain-start"
- "ictest-state-sync"
- "ictest-ibc-xfer"
- "ictest-packet-forward-middleware"
fail-fast: false

steps:
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: interchaintest/go.sum

- name: checkout chain
uses: actions/checkout@v4

- name: Download Tarball Artifact
uses: actions/download-artifact@v3
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 }}
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,30 @@ endif

.PHONY: cover-html run-tests $(TEST_TARGETS) test test-race docker-build-e2e

###############################################################################
### interchaintest ###
###############################################################################

ictest-sdk-commands: rm-testcache
cd interchaintest && go test -race -v -run TestCoreSDKCommands .

ictest-sdk-boundaries: rm-testcache
cd interchaintest && go test -race -v -run TestSDKBoundaries .

ictest-chain-start: rm-testcache
cd interchaintest && go test -race -v -run TestChainStart .

ictest-state-sync: rm-testcache
cd interchaintest && go test -race -v -run TestStateSync .

ictest-ibc-xfer: rm-testcache
cd interchaintest && go test -race -v -run TestIBCTransfer .

ictest-packet-forward-middleware: rm-testcache
cd interchaintest && go test -race -v -run TestPacketForwardMiddleware .

rm-testcache:
go clean -testcache

###############################################################################
### Release ###
Expand Down
25 changes: 21 additions & 4 deletions app/params/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package params

import (
"os"
"strconv"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"

Expand All @@ -10,17 +13,16 @@ import (
)

const (
HumanCoinUnit = "seda"
BaseCoinUnit = "aseda" // atto (10^-18)
SedaExponent = 18

HumanCoinUnit = "seda"
BaseCoinUnit = "aseda" // atto (10^-18)
DefaultBondDenom = BaseCoinUnit

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
Bech32PrefixAccAddr = "seda"
)

var (
SedaExponent int64
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key.
Bech32PrefixAccPub = Bech32PrefixAccAddr + "pub"
// Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address.
Expand All @@ -33,7 +35,22 @@ var (
Bech32PrefixConsPub = Bech32PrefixAccAddr + "valconspub"
)

func getSedaExponent() int64 {
sedaExponent := os.Getenv("SEDA_EXPONENT")
if sedaExponent == "" {
return 18 // default
}

value, err := strconv.Atoi(sedaExponent)
if err != nil {
panic(err)
}

return int64(value)
}

func init() {
SedaExponent = getSedaExponent()
SetAddressPrefixes()
RegisterDenoms()
}
Expand Down
4 changes: 4 additions & 0 deletions dockerfiles/Dockerfile.e2e
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ARG GO_VERSION="1.21"
ARG RUNNER_IMAGE="alpine:3.17"
ARG SEDA_EXPONENT="18"

# --------------------------------------------------------
# Builder
Expand Down Expand Up @@ -66,7 +67,10 @@ FROM ${RUNNER_IMAGE}

COPY --from=builder /seda-chain/build/seda-chaind /bin/seda-chaind

ARG SEDA_EXPONENT # use default if not set
ENV SEDA_EXPONENT=${SEDA_EXPONENT}
ENV HOME /seda-chain

WORKDIR $HOME

EXPOSE 26656 26657 1317 9090
Expand Down
4 changes: 2 additions & 2 deletions interchaintest/chain_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
upgradeName = "v1"
initialVersion = "old"
upgradeVersion = "new"
upgradeRepo = "sedaprotocol/seda-chaind-e2e"
upgradeRepo = "seda-chaind-e2e"
haltHeightDelta = uint64(10) // # of blocks after which to submit upgrade proposal
blocksAfterUpgrade = uint64(10) // # of blocks to wait after upgrade is applied
)
Expand All @@ -32,7 +32,7 @@ var (

// current chain version we are upgrading from
baseChain = ibc.DockerImage{
Repository: "sedaprotocol/seda-chaind-e2e", // to be replaced by sedaRepo once we have Docker images setup
Repository: "seda-chaind-e2e", // to be replaced by sedaRepo once we have Docker images setup
Version: initialVersion,
UidGid: "1025:1025",
}
Expand Down
8 changes: 4 additions & 4 deletions interchaintest/ibc_transfer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
)

// TestSedaGaiaIBCTransfer spins up a Seda and Gaia network, initializes an IBC connection between them,
// TestIBCTransfer spins up a Seda and Gaia network, initializes an IBC connection between them,
// and sends an ICS20 token transfer from Seda->Gaia and then back from Gaia->Seda.
func TestSedaGaiaIBCTransfer(t *testing.T) {
func TestIBCTransfer(t *testing.T) {
if testing.Short() {
t.Skip("skipping in short mode")
}
Expand Down Expand Up @@ -133,11 +133,11 @@ func runIBCTransferTest(t *testing.T, counterpartyChainSpec *interchaintest.Chai
// Get original account balances
sedaOrigBal, err := sedaChain.GetBalance(ctx, sedaUserAddr, sedaChain.Config().Denom)
require.NoError(t, err)
require.Equal(t, GenesisWalletAmount, sedaOrigBal.Int64())
require.Equal(t, GenesisWalletAmount, sedaOrigBal)

gaiaOrigBal, err := counterpartyChain.GetBalance(ctx, gaiaUserAddr, counterpartyChain.Config().Denom)
require.NoError(t, err)
require.Equal(t, GenesisWalletAmount, gaiaOrigBal.Int64())
require.Equal(t, GenesisWalletAmount, gaiaOrigBal)

/* =================================================== */
/* INTERCHAIN TEST */
Expand Down
4 changes: 2 additions & 2 deletions interchaintest/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ var (
SedaChainName = "seda"

dockerImage = ibc.DockerImage{
Repository: "sedaprotocol/seda-chaind-e2e", // FOR LOCAL IMAGE USE: Docker Image Name
Version: "latest", // FOR LOCAL IMAGE USE: Docker Image Tag
Repository: "seda-chaind-e2e", // FOR LOCAL IMAGE USE: Docker Image Name
Version: "latest", // FOR LOCAL IMAGE USE: Docker Image Tag
UidGid: "1025:1025",
}

Expand Down
Loading