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 conformance test for ibc #305

Merged
merged 8 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 7 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
85 changes: 85 additions & 0 deletions .github/workflows/e2e-ibc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: E2E-IBC

on:
pull_request:
push:
tags:
- "**"
branches:
- "main"

permissions:
contents: read
packages: write

env:
GO_VERSION: '1.20'
TAR_PATH: /tmp/fnsad-docker-image.tar
IMAGE_NAME: finschia

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

jobs:
build-docker:
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: .
tags: finschia:local
outputs: type=docker,dest=${{ env.TAR_PATH }}

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

e2e-tests:
needs: build-docker
runs-on: ubuntu-latest
strategy:
matrix:
# names of `make` commands to run tests
test:
- "test-e2e-ibc"
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 }}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (ci) [\#291](https://github.com/Finschia/finschia/pull/291) fix goreleaser ci error and replace release-build
* (repo) [\#295](https://github.com/Finschia/finschia/pull/295) setup CODEOWNERS and backport action
* (ci) [\#296](https://github.com/Finschia/finschia/pull/296) bump actions/checkout from 3 to 4
* (ci) [\#305](https://github.com/Finschia/finschia/pull/305) add e2e-ibc ci

### Docs

Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ SDK_PACK := $(shell go list -m github.com/Finschia/finschia-sdk | sed 's/ /\@/g
GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
OST_VERSION := $(shell go list -m github.com/Finschia/ostracon | sed 's:.* ::') # grab everything after the space in "github.com/Finschia/ostracon v0.34.7"
WASMVM_VERSION=$(shell go list -m github.com/Finschia/wasmvm | awk '{print $$2}')
HEIGHLINER_VERSION=v1.5.3
DOCKER := $(shell which docker)
LEDGER_ENABLED ?= true
BUILDDIR ?= $(CURDIR)/build
Expand Down Expand Up @@ -142,7 +143,18 @@ go-mod-cache: go.sum
@echo "--> Download go modules to local cache"
@go mod download

.PHONY: all build install clean wasmvmlib build-reproducible
get-heighliner:
git clone --branch $(HEIGHLINER_VERSION) https://github.com/strangelove-ventures/heighliner.git $(TEMPDIR)/heighliner
cd $(TEMPDIR)/heighliner && go install

local-image:
ifeq (,$(shell which heighliner))
echo 'heighliner' binary not found. Consider running `make get-heighliner`
else
heighliner build -c finschia --local --dockerfile cosmos --build-target "wget https://github.com/Finschia/wasmvm/releases/download/$(WASMVM_VERSION)/libwasmvm_muslc.aarch64.a -O /lib/libwasmvm.aarch64.a && make install" --binaries "/go/bin/fnsad"
endif

.PHONY: all build install clean wasmvmlib build-reproducible get-heighliner local-image


###############################################################################
Expand Down Expand Up @@ -176,8 +188,10 @@ test-integration-multi-node: docker-build
test-upgrade-name:
@sh contrib/check-upgrade-name.sh

.PHONY: test test-all test-unit test-race test-cover benchmark test-integration test-integration-multi-node
test-e2e-ibc:
cd interchaintest && go test -v ./...

.PHONY: test test-all test-unit test-race test-cover benchmark test-integration test-integration-multi-node test-e2e-ibc

###############################################################################
### Docker ###
Expand Down
15 changes: 15 additions & 0 deletions interchaintest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# IBC conformance test suite

# Quick Start

* Install and Build docker image for conformance test
```bash
# From finschia root folder
make get-heighliner
make local-image
```
* Run conformance test and other custom IBC tests
```bash
cd interchaintest
go test -v ./...
```
67 changes: 67 additions & 0 deletions interchaintest/conformance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package interchaintest_test

import (
"context"
"testing"

interchaintest "github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/conformance"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testreporter"
"go.uber.org/zap/zaptest"
)

func TestConformance(t *testing.T) {
// Arrange
numOfValidators := 2
numOfFullNodes := 0

cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
latestFinschiaChain(numOfValidators, numOfFullNodes),
builtinCosmosChainV13(numOfValidators, numOfFullNodes),
})

rlyFactory := interchaintest.NewBuiltinRelayerFactory(
ibc.CosmosRly,
zaptest.NewLogger(t),
)

// Act & Assert
conformance.Test(t, context.Background(), []interchaintest.ChainFactory{cf}, []interchaintest.RelayerFactory{rlyFactory}, testreporter.NewNopReporter())
}

func latestFinschiaChain(numOfValidators, numOfFullNodes int) *interchaintest.ChainSpec {
return &interchaintest.ChainSpec{
Version: "local",
ChainConfig: ibc.ChainConfig{
Type: "cosmos",
Name: "finschia-2",
ChainID: "finschia-2",
Images: []ibc.DockerImage{
{
Repository: "finschia",
Version: "local",
UidGid: "1025:1025",
},
},
Bin: "fnsad",
Bech32Prefix: "link",
Denom: "cony",
GasPrices: "0.15cony",
ulbqb marked this conversation as resolved.
Show resolved Hide resolved
GasAdjustment: 1.3,
TrustingPeriod: "336h",
},
NumValidators: &numOfValidators,
NumFullNodes: &numOfFullNodes,
}
}

func builtinCosmosChainV13(numOfValidators, numOfFullNodes int) *interchaintest.ChainSpec {
return &interchaintest.ChainSpec{
Name: "gaia",
ChainName: "cosmoshub-2",
Version: "v13.0.1",
NumValidators: &numOfValidators,
NumFullNodes: &numOfFullNodes,
}
}
Loading
Loading