Skip to content

Commit

Permalink
feat(e2e): created an e2e suite with ci (#28)
Browse files Browse the repository at this point in the history
* feat(e2e): ran 'go-codegen interchaintest scaffold'

* ci: added contract build step

* feat: using an 08-wasm image

* imp: reduced gov voting period

* imp: turned basic test into rollkit test

* style: renamed basic_test.go to rollkit_test.go

* fix: fixed genesis override

* feat: test passes

* imp: removed unused types module

* ci: fix

* deps(e2e): bump ibc-go
  • Loading branch information
srdtrk authored Apr 26, 2024
1 parent 215b18c commit c4a7fe4
Show file tree
Hide file tree
Showing 15 changed files with 3,260 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: e2e
on:
push:
branches: [main]
pull_request:
paths:
- '**.rs'
- '**.go'
- '**.toml'
- '**.lock'
- '.github/workflows/e2e.yml'
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.54
args: --timeout 5m
working-directory: e2e/interchaintestv8
build:
strategy:
fail-fast: false
matrix:
test:
# List your tests here
- TestWithRollkitTestSuite/TestInitialize
name: ${{ matrix.test }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Build Contracts with Docker
run: |
make build-cw
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache-dependency-path: |
e2e/interchaintestv8/go.sum
- name: Run Tests
run: |
cd e2e/interchaintestv8
go test -v -mod=readonly . -run=${{ matrix.test }}
- name: Upload Diagnostics on Failure
uses: actions/upload-artifact@v4
if: ${{ failure() }}
continue-on-error: true
with:
name: '${{ matrix.entrypoint }}-${{ matrix.test }}'
path: e2e/interchaintestv8/diagnostics
retention-days: 5
2 changes: 2 additions & 0 deletions e2e/interchaintestv8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore diagnostics directory
diagnostics/
82 changes: 82 additions & 0 deletions e2e/interchaintestv8/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
run:
tests: true
# # timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m

linters:
disable-all: true
enable:
- dogsled
- exportloopref
- errcheck
- gci
- goconst
- gocritic
- gofumpt
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- staticcheck
- thelper
- stylecheck
- revive
- typecheck
- unconvert
- unused
- misspell

issues:
exclude-rules:
- text: "unused-parameter"
linters:
- revive
- text: "SA1019:"
linters:
- staticcheck
- text: "Use of weak random number generator"
linters:
- gosec
- text: "ST1003:"
linters:
- stylecheck
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
linters:
- stylecheck
max-issues-per-linter: 10000
max-same-issues: 10000

linters-settings:
gci:
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- blank # blank imports
- dot # dot imports
- prefix(cosmossdk.io)
- prefix(github.com/cosmos/cosmos-sdk)
- prefix(github.com/cometbft/cometbft)
- prefix(github.com/cosmos/ibc-go)
- prefix(github.com/CosmWasm/wasmd)
- prefix(github.com/strangelove-ventures/interchaintest)
- prefix(github.com/cosmos/rollkit-ibc/e2e/interchaintest/v8)

custom-order: true
dogsled:
max-blank-identifiers: 3
maligned:
# print struct with more effective memory layout or not, false by default
suggest-new: true
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
revive:
rules:
- name: if-return
disabled: true
19 changes: 19 additions & 0 deletions e2e/interchaintestv8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# End to End Testing Suite with Interchaintest

The e2e tests are built using the [interchaintest](https://github.com/strangelove-ventures/interchaintest) library by Strangelove. It runs multiple docker container validators, and lets you test IBC enabled smart contracts.

These end to end tests are designed to run in the ci, but you can also run them locally.

## Running the tests locally

To run the tests locally, run the following commands from this directory:

```text
go test -v . -run=$TEST_SUITE_FN/$TEST_NAME
```

where `$TEST_NAME` is one of the test names of the `$TEST_SUITE_FN`. For example, to run the `TestInitialize` test, you would run:

```text
go test -v . -run=TestWithRollkitTestSuite/TestInitialize
```
57 changes: 57 additions & 0 deletions e2e/interchaintestv8/chainconfig/chain_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package chainconfig

import (
interchaintest "github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
)

var DefaultChainSpecs = []*interchaintest.ChainSpec{
// -- 08-WASM SIMD --
{
ChainConfig: ibc.ChainConfig{
Type: "cosmos",
Name: "simd-1",
ChainID: "simd-1",
Images: []ibc.DockerImage{
{
Repository: "ghcr.io/cosmos/ibc-go-wasm-simd", // FOR LOCAL IMAGE USE: Docker Image Name
Version: "v8.0.0-e2e-upgrade", // FOR LOCAL IMAGE USE: Docker Image Tag
UidGid: "1025:1025",
},
},
Bin: "simd",
Bech32Prefix: "cosmos",
Denom: "stake",
GasPrices: "0.00stake",
GasAdjustment: 1.3,
EncodingConfig: WasmEncodingConfig(),
ModifyGenesis: defaultModifyGenesis(),
TrustingPeriod: "508h",
NoHostMount: false,
},
},
// -- 08-WASM SIMD --
{
ChainConfig: ibc.ChainConfig{
Type: "cosmos",
Name: "simd-2",
ChainID: "simd-2",
Images: []ibc.DockerImage{
{
Repository: "ghcr.io/cosmos/ibc-go-wasm-simd", // FOR LOCAL IMAGE USE: Docker Image Name
Version: "v8.0.0-e2e-upgrade", // FOR LOCAL IMAGE USE: Docker Image Tag
UidGid: "1025:1025",
},
},
Bin: "simd",
Bech32Prefix: "cosmos",
Denom: "stake",
GasPrices: "0.00stake",
GasAdjustment: 1.3,
EncodingConfig: WasmEncodingConfig(),
ModifyGenesis: defaultModifyGenesis(),
TrustingPeriod: "508h",
NoHostMount: false,
},
},
}
114 changes: 114 additions & 0 deletions e2e/interchaintestv8/chainconfig/encoding.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package chainconfig

import (
"github.com/cosmos/gogoproto/proto"

txsigning "cosmossdk.io/x/tx/signing"
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/address"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdktestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
consensustypes "github.com/cosmos/cosmos-sdk/x/consensus/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
grouptypes "github.com/cosmos/cosmos-sdk/x/group"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
proposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

ibcwasmtypes "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types"
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
v7migrations "github.com/cosmos/ibc-go/v8/modules/core/02-client/migrations/v7"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine"
ibctmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
localhost "github.com/cosmos/ibc-go/v8/modules/light-clients/09-localhost"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
)

// WasmEncodingConfig returns the global E2E encoding config for Wasm.
func WasmEncodingConfig() *sdktestutil.TestEncodingConfig {
return encodingConfig("cosmos")
}

// EncodingConfig returns the global E2E encoding config.
// It includes CosmosSDK, IBC, and Wasm messages
func encodingConfig(bech32Prefix string) *sdktestutil.TestEncodingConfig {
amino := codec.NewLegacyAmino()
interfaceRegistry, err := codectypes.NewInterfaceRegistryWithOptions(codectypes.InterfaceRegistryOptions{
ProtoFiles: proto.HybridResolver,
SigningOptions: txsigning.Options{
AddressCodec: address.Bech32Codec{
Bech32Prefix: bech32Prefix,
},
ValidatorAddressCodec: address.Bech32Codec{
Bech32Prefix: bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator,
},
},
})
if err != nil {
panic(err)
}

// ibc types
icacontrollertypes.RegisterInterfaces(interfaceRegistry)
icahosttypes.RegisterInterfaces(interfaceRegistry)
feetypes.RegisterInterfaces(interfaceRegistry)
solomachine.RegisterInterfaces(interfaceRegistry)
v7migrations.RegisterInterfaces(interfaceRegistry)
transfertypes.RegisterInterfaces(interfaceRegistry)
clienttypes.RegisterInterfaces(interfaceRegistry)
channeltypes.RegisterInterfaces(interfaceRegistry)
connectiontypes.RegisterInterfaces(interfaceRegistry)
ibctmtypes.RegisterInterfaces(interfaceRegistry)
localhost.RegisterInterfaces(interfaceRegistry)
ibcwasmtypes.RegisterInterfaces(interfaceRegistry)

// sdk types
upgradetypes.RegisterInterfaces(interfaceRegistry)
banktypes.RegisterInterfaces(interfaceRegistry)
govv1beta1.RegisterInterfaces(interfaceRegistry)
govv1.RegisterInterfaces(interfaceRegistry)
authtypes.RegisterInterfaces(interfaceRegistry)
cryptocodec.RegisterInterfaces(interfaceRegistry)
grouptypes.RegisterInterfaces(interfaceRegistry)
proposaltypes.RegisterInterfaces(interfaceRegistry)
authz.RegisterInterfaces(interfaceRegistry)
txtypes.RegisterInterfaces(interfaceRegistry)
stakingtypes.RegisterInterfaces(interfaceRegistry)
minttypes.RegisterInterfaces(interfaceRegistry)
distrtypes.RegisterInterfaces(interfaceRegistry)
slashingtypes.RegisterInterfaces(interfaceRegistry)
consensustypes.RegisterInterfaces(interfaceRegistry)

// custom module types
wasmtypes.RegisterInterfaces(interfaceRegistry)

cdc := codec.NewProtoCodec(interfaceRegistry)

cfg := &sdktestutil.TestEncodingConfig{
InterfaceRegistry: interfaceRegistry,
Codec: cdc,
TxConfig: authtx.NewTxConfig(cdc, authtx.DefaultSignModes),
Amino: amino,
}

return cfg
}
Loading

0 comments on commit c4a7fe4

Please sign in to comment.