diff --git a/chain/cosmos/chain_node.go b/chain/cosmos/chain_node.go index e8bc45001..9b6f9c044 100644 --- a/chain/cosmos/chain_node.go +++ b/chain/cosmos/chain_node.go @@ -146,6 +146,10 @@ func (tn *ChainNode) Name() string { return fmt.Sprintf("%s-%s-%d-%s", tn.Chain.Config().ChainID, nodeType, tn.Index, dockerutil.SanitizeContainerName(tn.TestName)) } +func (tn *ChainNode) ContainerID() string { + return tn.containerLifecycle.ContainerID() +} + // hostname of the test node container func (tn *ChainNode) HostName() string { return dockerutil.CondenseHostName(tn.Name()) @@ -620,6 +624,11 @@ func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, gene } command = append(command, "add-genesis-account", address, amount) + + if tn.Chain.Config().UsingChainIDFlagCLI { + command = append(command, "--chain-id", tn.Chain.Config().ChainID) + } + _, _, err := tn.ExecBin(ctx, command...) return err diff --git a/chain/cosmos/cosmos_chain.go b/chain/cosmos/cosmos_chain.go index 9f8f9ce50..d1e6cb167 100644 --- a/chain/cosmos/cosmos_chain.go +++ b/chain/cosmos/cosmos_chain.go @@ -653,6 +653,10 @@ func (c *CosmosChain) Start(testName string, ctx context.Context, additionalGene Denom: chainCfg.Denom, } + if chainCfg.ModifyGenesisAmounts != nil { + genesisAmount, genesisSelfDelegation = chainCfg.ModifyGenesisAmounts() + } + genesisAmounts := []types.Coin{genesisAmount} configFileOverrides := chainCfg.ConfigFileOverrides diff --git a/chainspec.go b/chainspec.go index bcca6f36f..a975bc922 100644 --- a/chainspec.go +++ b/chainspec.go @@ -142,7 +142,12 @@ func (s *ChainSpec) applyConfigOverrides(cfg ibc.ChainConfig) (*ibc.ChainConfig, if s.PreGenesis != nil { cfg.PreGenesis = s.PreGenesis } + if s.ModifyGenesisAmounts != nil { + cfg.ModifyGenesisAmounts = s.ModifyGenesisAmounts + } + cfg.UsingNewGenesisCommand = s.UsingNewGenesisCommand + cfg.UsingChainIDFlagCLI = s.UsingChainIDFlagCLI // Set the version depending on the chain type. switch cfg.Type { diff --git a/ibc/types.go b/ibc/types.go index 2adeee09a..0e736c170 100644 --- a/ibc/types.go +++ b/ibc/types.go @@ -4,8 +4,15 @@ import ( "reflect" "strconv" +<<<<<<< HEAD simappparams "github.com/cosmos/cosmos-sdk/simapp/params" ibcexported "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" +======= + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/types/module/testutil" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" + sdk "github.com/cosmos/cosmos-sdk/types" +>>>>>>> 5fdb1e8 (feat(cosmos): Additional Helpers (#687)) ) // ChainConfig defines the chain parameters requires to run an interchaintest testnet for a chain. @@ -40,12 +47,21 @@ type ChainConfig struct { PreGenesis func(ChainConfig) error // When provided, genesis file contents will be altered before sharing for genesis. ModifyGenesis func(ChainConfig, []byte) ([]byte, error) + // Modify genesis-amounts + ModifyGenesisAmounts func() (sdk.Coin, sdk.Coin) // Override config parameters for files at filepath. ConfigFileOverrides map[string]any // Non-nil will override the encoding config, used for cosmos chains only. EncodingConfig *simappparams.EncodingConfig // Required when the chain uses the new sub commands for genesis (https://github.com/cosmos/cosmos-sdk/pull/14149) UsingNewGenesisCommand bool `yaml:"using-new-genesis-command"` +<<<<<<< HEAD +======= + // Required when the chain requires the chain-id field to be populated for certain commands + UsingChainIDFlagCLI bool `yaml:"using-chain-id-flag-cli"` + // Configuration describing additional sidecar processes. + SidecarConfigs []SidecarConfig +>>>>>>> 5fdb1e8 (feat(cosmos): Additional Helpers (#687)) } func (c ChainConfig) Clone() ChainConfig {