mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-13 03:25:20 +00:00
test: add packet-forwarding middleware e2e test (#1883)
* setup interchaintest IBC test * e2e test of packet forwarding middleware * rename interchain -> e2e-ibc & add make cmd * add CI step that runs e2e-ibc tests * use current branch for docker image in e2e-ibc
This commit is contained in:
parent
346f4be683
commit
d981070ede
12
.github/workflows/ci-default.yml
vendored
12
.github/workflows/ci-default.yml
vendored
@ -35,6 +35,18 @@ jobs:
|
||||
run: make test
|
||||
- name: run e2e tests
|
||||
run: make docker-build test-e2e
|
||||
ibc-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout repo from current commit
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: tests/e2e-ibc/go.mod
|
||||
cache-dependency-path: tests/e2e-ibc/go.sum
|
||||
- name: run ibc e2e tests
|
||||
run: make test-ibc
|
||||
validate-internal-testnet-genesis:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -1,2 +1,2 @@
|
||||
golang 1.21
|
||||
golang 1.21.9
|
||||
nodejs 18.16.0
|
||||
|
5
Makefile
5
Makefile
@ -306,6 +306,11 @@ test-basic: test
|
||||
test-e2e: docker-build
|
||||
$(GO_BIN) test -failfast -count=1 -v ./tests/e2e/...
|
||||
|
||||
# run interchaintest tests (./tests/e2e-ibc)
|
||||
test-ibc: docker-build
|
||||
cd tests/e2e-ibc && KAVA_TAG=local $(GO_BIN) test -timeout 10m .
|
||||
.PHONY: test-ibc
|
||||
|
||||
test:
|
||||
@$(GO_BIN) test $$($(GO_BIN) list ./... | grep -v 'contrib' | grep -v 'tests/e2e')
|
||||
|
||||
|
261
tests/e2e-ibc/go.mod
Normal file
261
tests/e2e-ibc/go.mod
Normal file
@ -0,0 +1,261 @@
|
||||
module github.com/kava-labs/kava/tests/interchain
|
||||
|
||||
go 1.21.9
|
||||
|
||||
replace (
|
||||
github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d
|
||||
github.com/ChainSafe/go-schnorrkel/1 => github.com/ChainSafe/go-schnorrkel v1.0.0
|
||||
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
|
||||
github.com/vedhavyas/go-subkey => github.com/strangelove-ventures/go-subkey v1.0.7
|
||||
)
|
||||
|
||||
require (
|
||||
cosmossdk.io/math v1.3.0
|
||||
github.com/cosmos/ibc-go/v8 v8.1.0
|
||||
github.com/strangelove-ventures/interchaintest/v8 v8.2.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
go.uber.org/zap v1.27.0
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.112.0 // indirect
|
||||
cloud.google.com/go/compute v1.23.3 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.2.3 // indirect
|
||||
cloud.google.com/go/iam v1.1.5 // indirect
|
||||
cloud.google.com/go/storage v1.36.0 // indirect
|
||||
cosmossdk.io/api v0.7.3 // indirect
|
||||
cosmossdk.io/collections v0.4.0 // indirect
|
||||
cosmossdk.io/core v0.11.0 // indirect
|
||||
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/store v1.0.2 // indirect
|
||||
cosmossdk.io/x/feegrant v0.1.0 // indirect
|
||||
cosmossdk.io/x/tx v0.13.0 // indirect
|
||||
cosmossdk.io/x/upgrade v0.1.1 // indirect
|
||||
filippo.io/edwards25519 v1.0.0 // indirect
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/99designs/keyring v1.2.2 // indirect
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
|
||||
github.com/ChainSafe/go-schnorrkel/1 v0.0.0-00010101000000-000000000000 // indirect
|
||||
github.com/ComposableFi/go-subkey/v2 v2.0.0-tm03420 // indirect
|
||||
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
|
||||
github.com/DataDog/zstd v1.5.5 // indirect
|
||||
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
|
||||
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
|
||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||
github.com/StirlingMarketingGroup/go-namecase v1.0.0 // indirect
|
||||
github.com/avast/retry-go/v4 v4.5.1 // indirect
|
||||
github.com/aws/aws-sdk-go v1.44.224 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.10.0 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/chzyer/readline v1.5.1 // indirect
|
||||
github.com/cockroachdb/errors v1.11.1 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
|
||||
github.com/cockroachdb/pebble v1.1.0 // indirect
|
||||
github.com/cockroachdb/redact v1.1.5 // indirect
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
||||
github.com/cometbft/cometbft v0.38.5 // indirect
|
||||
github.com/cometbft/cometbft-db v0.9.1 // indirect
|
||||
github.com/cosmos/btcutil v1.0.5 // indirect
|
||||
github.com/cosmos/cosmos-db v1.0.0 // indirect
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.4 // indirect
|
||||
github.com/cosmos/cosmos-sdk v0.50.4 // indirect
|
||||
github.com/cosmos/go-bip39 v1.0.0 // indirect
|
||||
github.com/cosmos/gogogateway v1.2.0 // indirect
|
||||
github.com/cosmos/gogoproto v1.4.11 // indirect
|
||||
github.com/cosmos/iavl v1.0.1 // indirect
|
||||
github.com/cosmos/ibc-go/modules/capability v1.0.0 // indirect
|
||||
github.com/cosmos/ics23/go v0.10.0 // indirect
|
||||
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
|
||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||
github.com/deckarep/golang-set v1.8.0 // indirect
|
||||
github.com/decred/base58 v1.0.4 // indirect
|
||||
github.com/decred/dcrd/crypto/blake256 v1.0.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v2 v2.0.1 // indirect
|
||||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
|
||||
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
|
||||
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
|
||||
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
||||
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
|
||||
github.com/docker/distribution v2.8.2+incompatible // indirect
|
||||
github.com/docker/docker v24.0.7+incompatible // indirect
|
||||
github.com/docker/go-connections v0.5.0 // indirect
|
||||
github.com/docker/go-units v0.5.0 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
|
||||
github.com/emicklei/dot v1.6.1 // indirect
|
||||
github.com/ethereum/go-ethereum v1.13.14 // indirect
|
||||
github.com/fatih/color v1.15.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/getsentry/sentry-go v0.27.0 // indirect
|
||||
github.com/go-kit/kit v0.12.0 // indirect
|
||||
github.com/go-kit/log v0.2.1 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/go-logr/logr v1.3.0 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
||||
github.com/gogo/googleapis v1.4.1 // indirect
|
||||
github.com/gogo/protobuf v1.3.3 // indirect
|
||||
github.com/golang/glog v1.2.0 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
|
||||
github.com/google/btree v1.1.2 // indirect
|
||||
github.com/google/go-cmp v0.6.0 // indirect
|
||||
github.com/google/orderedcode v0.0.1 // indirect
|
||||
github.com/google/s2a-go v0.1.7 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
|
||||
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
|
||||
github.com/gorilla/handlers v1.5.2 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/gorilla/websocket v1.5.0 // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
|
||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||
github.com/gtank/merlin v0.1.1 // indirect
|
||||
github.com/gtank/ristretto255 v0.1.2 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-getter v1.7.3 // indirect
|
||||
github.com/hashicorp/go-hclog v1.5.0 // indirect
|
||||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-metrics v0.5.2 // indirect
|
||||
github.com/hashicorp/go-plugin v1.5.2 // indirect
|
||||
github.com/hashicorp/go-safetemp v1.0.0 // indirect
|
||||
github.com/hashicorp/go-version v1.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/yamux v0.1.1 // indirect
|
||||
github.com/hdevalence/ed25519consensus v0.1.0 // indirect
|
||||
github.com/holiman/uint256 v1.2.4 // indirect
|
||||
github.com/huandu/skiplist v1.2.0 // indirect
|
||||
github.com/iancoleman/strcase v0.3.0 // indirect
|
||||
github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 // indirect
|
||||
github.com/improbable-eng/grpc-web v0.15.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/ipfs/go-cid v0.4.1 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
|
||||
github.com/klauspost/compress v1.17.6 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
|
||||
github.com/kr/pretty v0.3.1 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/lib/pq v1.10.7 // indirect
|
||||
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
||||
github.com/libp2p/go-libp2p v0.31.0 // indirect
|
||||
github.com/linxGnu/grocksdb v1.8.12 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/manifoldco/promptui v0.9.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mimoo/StrobeGo v0.0.0-20220103164710-9a04d6ca976b // indirect
|
||||
github.com/minio/highwayhash v1.0.2 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/misko9/go-substrate-rpc-client/v4 v4.0.0-20230913220906-b988ea7da0c2 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
github.com/multiformats/go-base32 v0.1.0 // indirect
|
||||
github.com/multiformats/go-base36 v0.2.0 // indirect
|
||||
github.com/multiformats/go-multiaddr v0.11.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.2.0 // indirect
|
||||
github.com/multiformats/go-multicodec v0.9.0 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.3 // indirect
|
||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
|
||||
github.com/oklog/run v1.1.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
|
||||
github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect
|
||||
github.com/pierrec/xxHash v0.1.5 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
|
||||
github.com/prometheus/client_golang v1.18.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.0 // indirect
|
||||
github.com/prometheus/common v0.47.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/rogpeppe/go-internal v1.12.0 // indirect
|
||||
github.com/rs/cors v1.8.3 // indirect
|
||||
github.com/rs/zerolog v1.32.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.4.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sasha-s/go-deadlock v0.3.1 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.6.0 // indirect
|
||||
github.com/spf13/cobra v1.8.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.18.2 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
github.com/tendermint/go-amino v0.16.0 // indirect
|
||||
github.com/tidwall/btree v1.7.0 // indirect
|
||||
github.com/tyler-smith/go-bip32 v1.0.0 // indirect
|
||||
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
|
||||
github.com/ulikunitz/xz v0.5.11 // indirect
|
||||
github.com/zondax/hid v0.9.2 // indirect
|
||||
github.com/zondax/ledger-go v0.14.3 // indirect
|
||||
go.etcd.io/bbolt v1.3.8 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
|
||||
go.opentelemetry.io/otel v1.21.0 // indirect
|
||||
go.opentelemetry.io/otel/metric v1.21.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.21.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.20.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
|
||||
golang.org/x/mod v0.15.0 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/oauth2 v0.16.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/term v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/time v0.5.0 // indirect
|
||||
golang.org/x/tools v0.18.0 // indirect
|
||||
google.golang.org/api v0.155.0 // indirect
|
||||
google.golang.org/appengine v1.6.8 // indirect
|
||||
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||
google.golang.org/grpc v1.62.0 // indirect
|
||||
google.golang.org/protobuf v1.32.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gotest.tools/v3 v3.5.1 // indirect
|
||||
lukechampine.com/blake3 v1.2.1 // indirect
|
||||
lukechampine.com/uint128 v1.2.0 // indirect
|
||||
modernc.org/cc/v3 v3.40.0 // indirect
|
||||
modernc.org/ccgo/v3 v3.16.13 // indirect
|
||||
modernc.org/libc v1.29.0 // indirect
|
||||
modernc.org/mathutil v1.6.0 // indirect
|
||||
modernc.org/memory v1.7.2 // indirect
|
||||
modernc.org/opt v0.1.3 // indirect
|
||||
modernc.org/sqlite v1.28.0 // indirect
|
||||
modernc.org/strutil v1.1.3 // indirect
|
||||
modernc.org/token v1.0.1 // indirect
|
||||
nhooyr.io/websocket v1.8.7 // indirect
|
||||
pgregory.net/rapid v1.1.0 // indirect
|
||||
sigs.k8s.io/yaml v1.4.0 // indirect
|
||||
)
|
1869
tests/e2e-ibc/go.sum
Normal file
1869
tests/e2e-ibc/go.sum
Normal file
File diff suppressed because it is too large
Load Diff
208
tests/e2e-ibc/main_test.go
Normal file
208
tests/e2e-ibc/main_test.go
Normal file
@ -0,0 +1,208 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
|
||||
|
||||
"github.com/strangelove-ventures/interchaintest/v8"
|
||||
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
|
||||
"github.com/strangelove-ventures/interchaintest/v8/ibc"
|
||||
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/zap/zaptest"
|
||||
)
|
||||
|
||||
func TestInterchainIBC(t *testing.T) {
|
||||
kavaImageTag := os.Getenv("KAVA_TAG")
|
||||
if kavaImageTag == "" {
|
||||
kavaImageTag = "v0.26.0-rocksdb"
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// setup chains
|
||||
cf := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
|
||||
{
|
||||
Name: "kava",
|
||||
ChainConfig: ibc.ChainConfig{
|
||||
Type: "cosmos",
|
||||
ChainID: "kava_8888-1",
|
||||
Images: []ibc.DockerImage{{Repository: "kava/kava", Version: kavaImageTag, UidGid: "0:0"}},
|
||||
Bin: "kava",
|
||||
Bech32Prefix: "kava",
|
||||
Denom: "ukava",
|
||||
GasPrices: "0ukava", // 0 gas price makes calculating expected balances simpler
|
||||
GasAdjustment: 1.5,
|
||||
TrustingPeriod: "168h0m0s",
|
||||
// ModifyGenesis: cosmos.ModifyGenesis(genesis), // TODO: configure evm things for internal bridge testing
|
||||
// CoinType: "60", // might need this to sign evm txs. will need to override decimals to be 6 again.
|
||||
},
|
||||
},
|
||||
{Name: "gaia", Version: "v15.2.0", ChainConfig: ibc.ChainConfig{GasPrices: "0.0uatom"}},
|
||||
{Name: "osmosis", Version: "v24.0.1"},
|
||||
})
|
||||
|
||||
chains, err := cf.Chains(t.Name())
|
||||
require.NoError(t, err)
|
||||
|
||||
kava, gaia, osmosis := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain), chains[2].(*cosmos.CosmosChain)
|
||||
|
||||
// setup relayer
|
||||
client, network := interchaintest.DockerSetup(t)
|
||||
r := interchaintest.NewBuiltinRelayerFactory(ibc.CosmosRly, zaptest.NewLogger(t)).
|
||||
Build(t, client, network)
|
||||
|
||||
// configure interchain
|
||||
const kavaGaiaIbcPath = "kava-gaia-demo"
|
||||
const kavaOsmosisIbcPath = "kava-osmo-demo"
|
||||
ic := interchaintest.NewInterchain().
|
||||
AddChain(kava).
|
||||
AddChain(gaia).
|
||||
AddChain(osmosis).
|
||||
AddRelayer(r, "relayer").
|
||||
AddLink(interchaintest.InterchainLink{
|
||||
Chain1: kava,
|
||||
Chain2: gaia,
|
||||
Relayer: r,
|
||||
Path: kavaGaiaIbcPath,
|
||||
}).
|
||||
AddLink(interchaintest.InterchainLink{
|
||||
Chain1: kava,
|
||||
Chain2: osmosis,
|
||||
Relayer: r,
|
||||
Path: kavaOsmosisIbcPath,
|
||||
})
|
||||
|
||||
// Log location
|
||||
f, err := interchaintest.CreateLogFile(fmt.Sprintf("%d.json", time.Now().Unix()))
|
||||
require.NoError(t, err)
|
||||
// Reporter/logs
|
||||
rep := testreporter.NewReporter(f)
|
||||
eRep := rep.RelayerExecReporter(t)
|
||||
|
||||
// Build interchain
|
||||
err = ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{
|
||||
TestName: t.Name(),
|
||||
Client: client,
|
||||
NetworkID: network,
|
||||
SkipPathCreation: false},
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// start the relayer so we don't need to manually Flush() packets
|
||||
err = r.StartRelayer(ctx, eRep, kavaGaiaIbcPath, kavaOsmosisIbcPath)
|
||||
require.NoError(t, err)
|
||||
defer r.StopRelayer(ctx, eRep)
|
||||
|
||||
// Create and Fund User Wallets
|
||||
fundAmount := math.NewInt(10_000_000)
|
||||
|
||||
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", fundAmount, kava, gaia, osmosis)
|
||||
kavaUser := users[0]
|
||||
gaiaUser := users[1]
|
||||
osmosisUser := users[2]
|
||||
|
||||
// wait for new block to ensure initial funding complete
|
||||
height, err := kava.Height(ctx)
|
||||
require.NoError(t, err)
|
||||
h := height
|
||||
for h <= height {
|
||||
h, err = kava.Height(ctx)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// check initial balance
|
||||
kavaUserBalInitial, err := kava.GetBalance(ctx, kavaUser.FormattedAddress(), kava.Config().Denom)
|
||||
require.NoError(t, err)
|
||||
require.True(t, kavaUserBalInitial.Equal(fundAmount))
|
||||
|
||||
// get ibc channel ids
|
||||
gaiaChannelInfo, err := r.GetChannels(ctx, eRep, gaia.Config().ChainID)
|
||||
require.NoError(t, err)
|
||||
osmoChannelInfo, err := r.GetChannels(ctx, eRep, osmosis.Config().ChainID)
|
||||
require.NoError(t, err)
|
||||
|
||||
gaiaToKavaChannelID := gaiaChannelInfo[0].ChannelID
|
||||
kavaToGaiaChannelID := gaiaChannelInfo[0].Counterparty.ChannelID
|
||||
osmoToKavaChannelID := osmoChannelInfo[0].ChannelID
|
||||
kavaToOsmoChannelID := osmoChannelInfo[0].Counterparty.ChannelID
|
||||
|
||||
// determine ibc denoms
|
||||
srcDenomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", gaiaToKavaChannelID, kava.Config().Denom))
|
||||
kavaOnGaiaDenom := srcDenomTrace.IBCDenom()
|
||||
srcDenomTrace = transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", osmoToKavaChannelID, kava.Config().Denom))
|
||||
kavaOnOsmoDenom := srcDenomTrace.IBCDenom()
|
||||
|
||||
amountToSend := math.NewInt(1_000_000)
|
||||
|
||||
// IBC transfer kava to cosmoshub
|
||||
// inspired by https://github.com/strangelove-ventures/interchaintest/blob/main/examples/ibc/learn_ibc_test.go
|
||||
t.Run("ibc transfer kava -> cosmoshub", func(t *testing.T) {
|
||||
dstAddress := gaiaUser.FormattedAddress()
|
||||
transfer := ibc.WalletAmount{
|
||||
Address: dstAddress,
|
||||
Denom: kava.Config().Denom,
|
||||
Amount: amountToSend,
|
||||
}
|
||||
|
||||
tx, err := kava.SendIBCTransfer(ctx, kavaToGaiaChannelID, kavaUser.KeyName(), transfer, ibc.TransferOptions{})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, tx.Validate())
|
||||
|
||||
// manually flush packets so we don't need to wait for the relayer
|
||||
require.NoError(t, r.Flush(ctx, eRep, kavaGaiaIbcPath, kavaToGaiaChannelID))
|
||||
|
||||
// verify balance deducted from kava account
|
||||
expectedBal := kavaUserBalInitial.Sub(amountToSend)
|
||||
kavaUserBalNew, err := kava.GetBalance(ctx, kavaUser.FormattedAddress(), kava.Config().Denom)
|
||||
require.NoError(t, err)
|
||||
require.True(t, kavaUserBalNew.Equal(expectedBal))
|
||||
|
||||
// verify cosmoshub account received funds
|
||||
gaiaUserBalNew, err := gaia.GetBalance(ctx, gaiaUser.FormattedAddress(), kavaOnGaiaDenom)
|
||||
require.NoError(t, err)
|
||||
require.True(t, gaiaUserBalNew.Equal(amountToSend))
|
||||
})
|
||||
|
||||
// use coins IBC'd to cosmoshub, send them to osmosis using pfm
|
||||
t.Run("packet forwarding middleware: cosmoshub -> kava -> osmosis", func(t *testing.T) {
|
||||
dstAddress := osmosisUser.FormattedAddress()
|
||||
transfer := ibc.WalletAmount{
|
||||
Address: "pfm", // purposefully invalid b/c we are forwarding through kava onward to osmosis!
|
||||
Denom: kavaOnGaiaDenom,
|
||||
Amount: amountToSend,
|
||||
}
|
||||
|
||||
tx, err := gaia.SendIBCTransfer(ctx, gaiaToKavaChannelID, gaiaUser.KeyName(), transfer, ibc.TransferOptions{
|
||||
// packet forwarding middleware!
|
||||
Memo: fmt.Sprintf(`{
|
||||
"forward": {
|
||||
"receiver": "%s",
|
||||
"port": "transfer",
|
||||
"channel": "%s"
|
||||
}
|
||||
}`, dstAddress, kavaToOsmoChannelID),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, tx.Validate())
|
||||
|
||||
require.Eventually(t, func() bool {
|
||||
// verify transfer to osmosis
|
||||
osmosisUserBalNew, err := osmosis.GetBalance(ctx, osmosisUser.FormattedAddress(), kavaOnOsmoDenom)
|
||||
require.NoError(t, err)
|
||||
return osmosisUserBalNew.Equal(amountToSend)
|
||||
}, 15*time.Second, time.Second, "osmosis never received funds")
|
||||
|
||||
// verify cosmoshub account no longer has the funds
|
||||
gaiaUserBalNew, err := gaia.GetBalance(ctx, gaiaUser.FormattedAddress(), kavaOnGaiaDenom)
|
||||
require.NoError(t, err)
|
||||
require.True(t, gaiaUserBalNew.Equal(math.ZeroInt()))
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user