forked from celestiaorg/celestia-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: interchain accounts via interchaintest (celestiaorg#3308)
Closes celestiaorg#3207. For posterity, [this branch](https://github.com/rootulp/celestia-app/tree/rp/ica-tests) contains a messy commit history that describes issues encountered when setting up these tests.
- Loading branch information
1 parent
a2372a3
commit 5ba1b83
Showing
10 changed files
with
2,140 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ go 1.22.2 | |
use ( | ||
. | ||
./test/testground | ||
./test/interchain | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Interchain | ||
|
||
This folder contains tests that use [interchaintest](https://github.com/strangelove-ventures/interchaintest) to assert IBC features work as expected. Candidates for testing include: | ||
|
||
1. Interchain Accounts (ICA) | ||
1. Packet Forward Middleware (PFM) | ||
|
||
## Usage | ||
|
||
Run the tests via | ||
|
||
```bash | ||
make test-interchain | ||
``` | ||
|
||
## Contributing | ||
|
||
If you have local modifications that you would like to test via interchaintest, you'll need to create a new Celestia Docker image with your modifications. CI should automatically create a Docker image and publish it to GHCR if you create a PR against celestia-app. If that doesn't work, you can manually create an image via: | ||
|
||
```shell | ||
# make local modifications and commit them | ||
make build-ghcr-docker | ||
make publish-ghcr-docker | ||
``` | ||
|
||
After you have a new Docker image with your modifications, you must update the test to reference the new image (see `chainspec/celestia.go`). | ||
|
||
## Troubleshooting | ||
|
||
`interchaintest` issues can be difficult to debug. Here are a few tips that may help: | ||
|
||
1. You can stop `interchaintest` from cleaning up the Docker containers it created by setting an environment variable: | ||
|
||
```shell | ||
export KEEP_CONTAINERS=true | ||
``` | ||
|
||
See [this PR](https://github.com/strangelove-ventures/interchaintest/pull/725). It wasn't backported to the `v6` branch so if you want to use it, cherry-pick the commit locally and apply it to your local `interchaintest` fork and use Go mod replace to point interchaintest to your local fork. After you have that change, you can run commands on the docker containers to debug them. For example: | ||
```shell | ||
docker exec -it gaia-val-0-TestICA gaiad tx interchain-accounts controller register connection-0 \ | ||
--chain-id gaia \ | ||
--node http://gaia-val-0-TestICA:26657 \ | ||
--home /var/cosmos-chain/gaia-2 \ | ||
--from TestICA-gaia-pez \ | ||
--keyring-backend test \ | ||
--fees 300000uatom \ | ||
--gas 300000 \ | ||
--yes | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package chainspec | ||
|
||
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/testutil" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zaptest" | ||
) | ||
|
||
const ( | ||
celestiaDockerRepository = "ghcr.io/celestiaorg/celestia-app" | ||
celestiaDockerTag = "pr-3182" | ||
celestiaUidGid = "10001:10001" | ||
) | ||
|
||
// GetCelestia returns a CosmosChain for Celestia. | ||
func GetCelestia(t *testing.T) *cosmos.CosmosChain { | ||
factory := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{celestia}) | ||
chains, err := factory.Chains(t.Name()) | ||
require.NoError(t, err) | ||
return chains[0].(*cosmos.CosmosChain) | ||
} | ||
|
||
var celestia = &interchaintest.ChainSpec{ | ||
Name: "celestia", | ||
ChainConfig: ibc.ChainConfig{ | ||
Type: "cosmos", | ||
Name: "celestia-app", | ||
ChainID: "celestia", | ||
Bin: "celestia-appd", | ||
Bech32Prefix: "celestia", | ||
Denom: "utia", | ||
GasPrices: "0.002utia", | ||
GasAdjustment: *gasAdjustment(), | ||
TrustingPeriod: "336hours", | ||
Images: celestiaDockerImages(), | ||
ConfigFileOverrides: celestiaConfigFileOverrides(), | ||
}, | ||
NumValidators: numValidators(), | ||
NumFullNodes: numFullNodes(), | ||
GasAdjustment: gasAdjustment(), | ||
} | ||
|
||
func celestiaDockerImages() []ibc.DockerImage { | ||
return []ibc.DockerImage{ | ||
{ | ||
Repository: celestiaDockerRepository, | ||
Version: celestiaDockerTag, | ||
UidGid: celestiaUidGid, | ||
}, | ||
} | ||
} | ||
|
||
func celestiaConfigFileOverrides() map[string]any { | ||
txIndex := make(testutil.Toml) | ||
txIndex["indexer"] = "kv" | ||
|
||
storage := make(testutil.Toml) | ||
storage["discard_abci_responses"] = false | ||
|
||
configToml := make(testutil.Toml) | ||
configToml["tx_index"] = txIndex | ||
configToml["storage"] = storage | ||
|
||
result := make(map[string]any) | ||
result["config/config.toml"] = configToml | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package chainspec | ||
|
||
func numValidators() *int { | ||
nodes := 1 | ||
return &nodes | ||
} | ||
|
||
func numFullNodes() *int { | ||
nodes := 0 | ||
return &nodes | ||
} | ||
|
||
func gasAdjustment() *float64 { | ||
gasAdjustment := 2.0 | ||
return &gasAdjustment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package chainspec | ||
|
||
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" | ||
) | ||
|
||
const ( | ||
// TODO: As of this writing, gaia has no official releases with the ICA | ||
// controller enabled. However, they do have it enabled on `main` so the | ||
// Docker image below is a custom build from `main`. Replace this with an | ||
// official release when available (likely >= 16.0.0). | ||
cosmosDockerRepository = "docker.io/rootulp/gaia" | ||
cosmosDockerVersion = "ica-controller" | ||
cosmosUidGid = "1025:1025" | ||
) | ||
|
||
// GetCosmosHub returns a CosmosChain for the CosmosHub. | ||
func GetCosmosHub(t *testing.T) *cosmos.CosmosChain { | ||
factory := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{cosmosHub}) | ||
chains, err := factory.Chains(t.Name()) | ||
require.NoError(t, err) | ||
return chains[0].(*cosmos.CosmosChain) | ||
} | ||
|
||
var cosmosHub = &interchaintest.ChainSpec{ | ||
Name: "gaia", | ||
ChainConfig: ibc.ChainConfig{ | ||
Name: "gaia", | ||
Type: "cosmos", | ||
ChainID: "gaia", | ||
Bin: "gaiad", | ||
Bech32Prefix: "cosmos", | ||
Denom: "uatom", | ||
GasPrices: "0.01uatom", | ||
GasAdjustment: *gasAdjustment(), | ||
TrustingPeriod: "504hours", | ||
NoHostMount: false, | ||
Images: cosmosDockerImages(), | ||
UsingNewGenesisCommand: true, | ||
}, | ||
NumValidators: numValidators(), | ||
NumFullNodes: numFullNodes(), | ||
GasAdjustment: gasAdjustment(), // the default gas estimation fails to create a client on Cosmos Hub so we need to bump it up. | ||
} | ||
|
||
func cosmosDockerImages() []ibc.DockerImage { | ||
return []ibc.DockerImage{ | ||
{ | ||
Repository: cosmosDockerRepository, | ||
Version: cosmosDockerVersion, | ||
UidGid: cosmosUidGid, | ||
}, | ||
} | ||
} |
Oops, something went wrong.