Skip to content

Commit

Permalink
feat(cosmos): Additional Helpers (#687)
Browse files Browse the repository at this point in the history
* injective / evm fixes

* chain-id flag conditional

(cherry picked from commit 5fdb1e8)

# Conflicts:
#	ibc/types.go
  • Loading branch information
nivasan1 authored and mergify[bot] committed Aug 10, 2023
1 parent ab3a123 commit b3fdbaf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chain/cosmos/chain_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,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())
Expand Down Expand Up @@ -640,6 +644,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
Expand Down
4 changes: 4 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,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
Expand Down
5 changes: 5 additions & 0 deletions chainspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 145 in chainspec.go

View workflow job for this annotation

GitHub Actions / lint

s.ModifyGenesisAmounts undefined (type *ChainSpec has no field or method ModifyGenesisAmounts) (typecheck)
cfg.ModifyGenesisAmounts = s.ModifyGenesisAmounts

Check failure on line 146 in chainspec.go

View workflow job for this annotation

GitHub Actions / lint

s.ModifyGenesisAmounts undefined (type *ChainSpec has no field or method ModifyGenesisAmounts) (typecheck)
}

cfg.UsingNewGenesisCommand = s.UsingNewGenesisCommand
cfg.UsingChainIDFlagCLI = s.UsingChainIDFlagCLI

Check failure on line 150 in chainspec.go

View workflow job for this annotation

GitHub Actions / lint

s.UsingChainIDFlagCLI undefined (type *ChainSpec has no field or method UsingChainIDFlagCLI) (typecheck)

// Set the version depending on the chain type.
switch cfg.Type {
Expand Down
16 changes: 16 additions & 0 deletions ibc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import (
"reflect"
"strconv"

<<<<<<< HEAD

Check failure on line 7 in ibc/types.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)

Check failure on line 7 in ibc/types.go

View workflow job for this annotation

GitHub Actions / unit-tests

expected 'STRING', found '<<'

Check failure on line 7 in ibc/types.go

View workflow job for this annotation

GitHub Actions / unit-tests

expected 'STRING', found '<<'

Check failure on line 7 in ibc/types.go

View workflow job for this annotation

GitHub Actions / test-conformance

expected 'STRING', found '<<'

Check failure on line 7 in ibc/types.go

View workflow job for this annotation

GitHub Actions / test-ibc-examples

expected 'STRING', found '<<'

Check failure on line 7 in ibc/types.go

View workflow job for this annotation

GitHub Actions / test-cosmos-examples

expected 'STRING', found '<<'
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
=======

Check failure on line 10 in ibc/types.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
"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))

Check failure on line 15 in ibc/types.go

View workflow job for this annotation

GitHub Actions / lint

missing import path (typecheck)
)

// ChainConfig defines the chain parameters requires to run an interchaintest testnet for a chain.
Expand Down Expand Up @@ -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

Check failure on line 58 in ibc/types.go

View workflow job for this annotation

GitHub Actions / lint

expected '}', found '<<' (typecheck)
=======
// 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))

Check failure on line 64 in ibc/types.go

View workflow job for this annotation

GitHub Actions / lint

illegal character U+0023 '#' (typecheck)
}

func (c ChainConfig) Clone() ChainConfig {
Expand Down

0 comments on commit b3fdbaf

Please sign in to comment.