Skip to content

Commit

Permalink
add support for version specific actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Oct 1, 2024
1 parent eb34a79 commit a8b50a6
Show file tree
Hide file tree
Showing 19 changed files with 4,602 additions and 1,698 deletions.
722 changes: 247 additions & 475 deletions tests/e2e/actions.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions tests/e2e/actions_consumer_misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ type ForkConsumerChainAction struct {
}

func (tc Chain) forkConsumerChain(action ForkConsumerChainAction, verbose bool) {
valCfg := tc.testConfig.validatorConfigs[action.Validator]
valCfg := tc.testConfig.ValidatorConfigs[action.Validator]
configureNodeCmd := tc.target.ExecCommand("/bin/bash",
"/testnet-scripts/fork-consumer.sh", tc.testConfig.chainConfigs[action.ConsumerChain].BinaryName,
"/testnet-scripts/fork-consumer.sh", tc.testConfig.ChainConfigs[action.ConsumerChain].BinaryName,
string(action.Validator), string(action.ConsumerChain),
tc.testConfig.chainConfigs[action.ConsumerChain].IpPrefix,
tc.testConfig.chainConfigs[action.ProviderChain].IpPrefix,
tc.testConfig.ChainConfigs[action.ConsumerChain].IpPrefix,
tc.testConfig.ChainConfigs[action.ProviderChain].IpPrefix,
valCfg.Mnemonic,
action.RelayerConfig,
)
Expand Down
33 changes: 14 additions & 19 deletions tests/e2e/actions_sovereign_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,17 @@ import (
"fmt"
"log"
"time"
)

type StartSovereignChainAction struct {
Chain ChainID
Validators []StartChainValidator
// Genesis changes specific to this action, appended to genesis changes defined in chain config
GenesisChanges string
}
e2e "github.com/cosmos/interchain-security/v6/tests/e2e/testlib"
)

// calls a simplified startup script (start-sovereign.sh) and runs a validator node
// upgrades are simpler with a single validator node since only one node needs to be upgraded
func (tr Chain) startSovereignChain(
action StartSovereignChainAction,
action e2e.StartSovereignChainAction,
verbose bool,
) {
chainConfig := tr.testConfig.chainConfigs["sover"]
chainConfig := tr.testConfig.ChainConfigs["sover"]
type jsonValAttrs struct {
Mnemonic string `json:"mnemonic"`
Allocation string `json:"allocation"`
Expand All @@ -39,18 +34,18 @@ func (tr Chain) startSovereignChain(
var validators []jsonValAttrs
for _, val := range action.Validators {
validators = append(validators, jsonValAttrs{
Mnemonic: tr.testConfig.validatorConfigs[val.Id].Mnemonic,
NodeKey: tr.testConfig.validatorConfigs[val.Id].NodeKey,
Mnemonic: tr.testConfig.ValidatorConfigs[val.Id].Mnemonic,
NodeKey: tr.testConfig.ValidatorConfigs[val.Id].NodeKey,
ValId: fmt.Sprint(val.Id),
PrivValidatorKey: tr.testConfig.validatorConfigs[val.Id].PrivValidatorKey,
PrivValidatorKey: tr.testConfig.ValidatorConfigs[val.Id].PrivValidatorKey,
Allocation: fmt.Sprint(val.Allocation) + "stake",
Stake: fmt.Sprint(val.Stake) + "stake",
IpSuffix: tr.testConfig.validatorConfigs[val.Id].IpSuffix,
IpSuffix: tr.testConfig.ValidatorConfigs[val.Id].IpSuffix,

ConsumerMnemonic: tr.testConfig.validatorConfigs[val.Id].ConsumerMnemonic,
ConsumerPrivValidatorKey: tr.testConfig.validatorConfigs[val.Id].ConsumerPrivValidatorKey,
ConsumerMnemonic: tr.testConfig.ValidatorConfigs[val.Id].ConsumerMnemonic,
ConsumerPrivValidatorKey: tr.testConfig.ValidatorConfigs[val.Id].ConsumerPrivValidatorKey,
// if true node will be started with consumer key for each consumer chain
StartWithConsumerKey: tr.testConfig.validatorConfigs[val.Id].UseConsumerKey,
StartWithConsumerKey: tr.testConfig.ValidatorConfigs[val.Id].UseConsumerKey,
})
}

Expand All @@ -71,7 +66,7 @@ func (tr Chain) startSovereignChain(
testScriptPath := tr.target.GetTestScriptPath(isConsumer, "start-sovereign.sh")
cmd := tr.target.ExecCommand("/bin/bash", testScriptPath, chainConfig.BinaryName, string(vals),
string(chainConfig.ChainId), chainConfig.IpPrefix, genesisChanges,
tr.testConfig.tendermintConfigOverride)
tr.testConfig.TendermintConfigOverride)

cmdReader, err := cmd.StdoutPipe()
if err != nil {
Expand Down Expand Up @@ -113,7 +108,7 @@ type UpgradeProposalAction struct {

func (tr *Chain) submitUpgradeProposal(action UpgradeProposalAction, verbose bool) {
// Get authority address
binary := tr.testConfig.chainConfigs[ChainID("sover")].BinaryName
binary := tr.testConfig.ChainConfigs[ChainID("sover")].BinaryName
cmd := tr.target.ExecCommand(binary,
"query", "upgrade", "authority",
"--node", tr.getValidatorNode(ChainID("sover"), action.Proposer),
Expand Down Expand Up @@ -171,7 +166,7 @@ func (tr *Chain) submitUpgradeProposal(action UpgradeProposalAction, verbose boo
"--gas", "900000",
"--from", "validator"+string(action.Proposer),
"--keyring-backend", "test",
"--chain-id", string(tr.testConfig.chainConfigs[ChainID("sover")].ChainId),
"--chain-id", string(tr.testConfig.ChainConfigs[ChainID("sover")].ChainId),
"--home", tr.getValidatorHome(ChainID("sover"), action.Proposer),
"--node", tr.getValidatorNode(ChainID("sover"), action.Proposer),
"-y")
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ func buildDockerImage(version string, targetCfg TargetConfig, noCache bool) (str
out, err := cmd.CombinedOutput()
if err != nil && !noCache {
// Retry image creation from pristine state by enforcing --no-cache
log.Printf("Image creation failed '%v'. Re-trying without cache!", err)
log.Printf("Image creation failed '%v'.\n%s\nRe-trying without cache!",
err, string(out))
return buildDockerImage(version, targetCfg, true)
}
if err != nil {
Expand Down
Loading

0 comments on commit a8b50a6

Please sign in to comment.