Skip to content

Commit

Permalink
refactor: chain setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Feb 24, 2024
1 parent 5542c59 commit 31ef003
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ test-coverage:
@export VERSION=$(VERSION); bash -x scripts/test_cover.sh
.PHONY: test-coverage

## test-fuzz: Run all fuzz tests.
test-fuzz:
bash -x scripts/test_fuzz.sh
.PHONY: test-fuzz
Expand Down
14 changes: 13 additions & 1 deletion interchaintest/chains.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package interchaintest_test

import (
"testing"

"github.com/strangelove-ventures/interchaintest/v6"
"github.com/strangelove-ventures/interchaintest/v6/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v6/ibc"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)

var chainSpecs = []*interchaintest.ChainSpec{celestiaSpec, cosmosSpec}
var celestiaSpec = &interchaintest.ChainSpec{
Name: "celestia",
ChainConfig: ibc.ChainConfig{
Expand All @@ -28,3 +31,12 @@ var cosmosSpec = &interchaintest.ChainSpec{
ChainConfig: cosmos.NewCosmosHeighlinerChainConfig("gaia", "gaiad", "cosmos", "uatom", "0.01uatom", 1.3, "504h", false),
Version: "v14.1.0",
}

// getChains returns two chains for testing: celestia and gaia.
func getChains(t *testing.T) (celestia *cosmos.CosmosChain, gaia *cosmos.CosmosChain) {
chainSpecs := []*interchaintest.ChainSpec{celestiaSpec, cosmosSpec}
chainFactory := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), chainSpecs)
chains, err := chainFactory.Chains(t.Name())
require.NoError(t, err)
return chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain)
}
28 changes: 13 additions & 15 deletions interchaintest/ica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"testing"

"github.com/strangelove-ventures/interchaintest/v6"
"github.com/strangelove-ventures/interchaintest/v6/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v6/ibc"
"github.com/strangelove-ventures/interchaintest/v6/relayer"
"github.com/strangelove-ventures/interchaintest/v6/testreporter"
Expand All @@ -22,35 +21,34 @@ func TestICA(t *testing.T) {
t.Skip("skipping TestICA in short mode.")
}

ctx := context.Background()
client, network := interchaintest.DockerSetup(t)
rep := testreporter.NewNopReporter()
eRep := rep.RelayerExecReporter(t)
chainFactory := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), chainSpecs)
chains, err := chainFactory.Chains(t.Name())
require.NoError(t, err)
chain1, chain2 := chains[0].(*cosmos.CosmosChain), chains[1].(*cosmos.CosmosChain)
celestia, gaia := getChains(t)

relayer := interchaintest.NewBuiltinRelayerFactory(
ibc.CosmosRly,
zaptest.NewLogger(t),
relayer.RelayerOptionExtraStartFlags{Flags: []string{"-p", "events", "-b", "100"}},
).Build(t, client, network)

ic := interchaintest.NewInterchain().
AddChain(chain1).
AddChain(chain2).
AddChain(celestia).
AddChain(gaia).
AddRelayer(relayer, relayerName).
AddLink(interchaintest.InterchainLink{
Chain1: chain1,
Chain2: chain2,
Chain1: celestia,
Chain2: gaia,
Relayer: relayer,
Path: path,
})
require.NoError(t, ic.Build(ctx, eRep, interchaintest.InterchainBuildOptions{

ctx := context.Background()
rep := testreporter.NewNopReporter().RelayerExecReporter(t)
// Build the interchain
err := ic.Build(ctx, rep, interchaintest.InterchainBuildOptions{
TestName: t.Name(),
Client: client,
NetworkID: network,
SkipPathCreation: true,
}))

})
require.NoError(t, err)
}

0 comments on commit 31ef003

Please sign in to comment.