Skip to content

Commit

Permalink
Merge branch 'marius/894-preccv' of github.com:cosmos/interchain-secu…
Browse files Browse the repository at this point in the history
…rity into marius/894-preccv
  • Loading branch information
mpoke committed Jan 7, 2025
2 parents 479421e + 015037d commit 530b52d
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 2,217 deletions.
45 changes: 0 additions & 45 deletions tests/e2e/action_rapid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ func MarshalAndUnmarshalAction(action interface{}) error {
// include generators for all actions that are mentioned in main.go/runStep.
func GetActionGen() *rapid.Generator[any] {
return rapid.OneOf(
GetStartSovereignChainActionGen().AsAny(),
GetSubmitLegacyUpgradeProposalActionGen().AsAny(),
GetWaitUntilBlockActionGen().AsAny(),
GetChangeoverChainActionGen().AsAny(),
GetSendTokensActionGen().AsAny(),
GetStartChainActionGen().AsAny(),
GetSubmitTextProposalActionGen().AsAny(),
Expand Down Expand Up @@ -154,47 +150,6 @@ func GetCreateIbcClientsActionGen() *rapid.Generator[CreateIbcClientsAction] {
})
}

func GetStartSovereignChainActionGen() *rapid.Generator[StartSovereignChainAction] {
return rapid.Custom(func(t *rapid.T) StartSovereignChainAction {
return StartSovereignChainAction{
Chain: GetChainIDGen().Draw(t, "Chain"),
Validators: GetStartChainValidatorsGen().Draw(t, "Validators"),
GenesisChanges: rapid.String().Draw(t, "GenesisChanges"),
}
})
}

func GetSubmitLegacyUpgradeProposalActionGen() *rapid.Generator[UpgradeProposalAction] {
return rapid.Custom(func(t *rapid.T) UpgradeProposalAction {
return UpgradeProposalAction{
ChainID: GetChainIDGen().Draw(t, "ChainID"),
UpgradeTitle: rapid.String().Draw(t, "UpgradeTitle"),
Proposer: GetValidatorIDGen().Draw(t, "Proposer"),
UpgradeHeight: rapid.Uint64().Draw(t, "UpgradeHeight"),
}
})
}

func GetWaitUntilBlockActionGen() *rapid.Generator[WaitUntilBlockAction] {
return rapid.Custom(func(t *rapid.T) WaitUntilBlockAction {
return WaitUntilBlockAction{
Chain: GetChainIDGen().Draw(t, "Chain"),
Block: rapid.Uint().Draw(t, "Block"),
}
})
}

func GetChangeoverChainActionGen() *rapid.Generator[ChangeoverChainAction] {
return rapid.Custom(func(t *rapid.T) ChangeoverChainAction {
return ChangeoverChainAction{
SovereignChain: GetChainIDGen().Draw(t, "SovereignChain"),
ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"),
Validators: GetStartChainValidatorsGen().Draw(t, "Validators"),
GenesisChanges: rapid.String().Draw(t, "GenesisChanges"),
}
})
}

func GetSendTokensActionGen() *rapid.Generator[SendTokensAction] {
return rapid.Custom(func(t *rapid.T) SendTokensAction {
return SendTokensAction{
Expand Down
107 changes: 0 additions & 107 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ type (
StartChainAction = e2e.StartChainAction
StartChainValidator = e2e.StartChainValidator
StartConsumerChainAction = e2e.StartConsumerChainAction
StartSovereignChainAction = e2e.StartSovereignChainAction
SubmitConsumerAdditionProposalAction = e2e.SubmitConsumerAdditionProposalAction
SubmitConsumerRemovalProposalAction = e2e.SubmitConsumerRemovalProposalAction
DelegateTokensAction = e2e.DelegateTokensAction
UnbondTokensAction = e2e.UnbondTokensAction
ChangeoverChainAction = e2e.ChangeoverChainAction
)

type SendTokensAction struct {
Expand Down Expand Up @@ -1100,111 +1098,6 @@ func (tr *Chain) transformConsumerGenesis(targetVersion string, genesis []byte)
return result
}

func (tr Chain) changeoverChain(
action e2e.ChangeoverChainAction,
verbose bool,
) {
consumerGenesis := ".app_state.ccvconsumer = " + tr.getConsumerGenesis(action.ProviderChain, action.SovereignChain)

consumerGenesisChanges := tr.testConfig.ChainConfigs[action.SovereignChain].GenesisChanges
if consumerGenesisChanges != "" {
consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges
}
if action.GenesisChanges != "" {
consumerGenesis = consumerGenesis + " | " + action.GenesisChanges
}

tr.startChangeover(e2e.ChangeoverChainAction{
Validators: action.Validators,
GenesisChanges: consumerGenesis,
}, verbose)
}

func (tr Chain) startChangeover(
action e2e.ChangeoverChainAction,
verbose bool,
) {
chainConfig := tr.testConfig.ChainConfigs[ChainID("sover")]
type jsonValAttrs struct {
Mnemonic string `json:"mnemonic"`
Allocation string `json:"allocation"`
Stake string `json:"stake"`
ValId string `json:"val_id"`
PrivValidatorKey string `json:"priv_validator_key"`
NodeKey string `json:"node_key"`
IpSuffix string `json:"ip_suffix"`

ConsumerMnemonic string `json:"consumer_mnemonic"`
ConsumerPrivValidatorKey string `json:"consumer_priv_validator_key"`
StartWithConsumerKey bool `json:"start_with_consumer_key"`
}

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,
ValId: fmt.Sprint(val.Id),
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,

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,
})
}

vals, err := json.Marshal(validators)
if err != nil {
log.Fatal(err)
}

// Concat genesis changes defined in chain config, with any custom genesis changes for this chain instantiation
var genesisChanges string
if action.GenesisChanges != "" {
genesisChanges = chainConfig.GenesisChanges + " | " + action.GenesisChanges
} else {
genesisChanges = chainConfig.GenesisChanges
}

isConsumer := true
changeoverScript := tr.target.GetTestScriptPath(isConsumer, "start-changeover.sh")
cmd := tr.target.ExecCommand(
"/bin/bash",
changeoverScript, chainConfig.UpgradeBinary, string(vals),
"sover", chainConfig.IpPrefix, genesisChanges,
tr.testConfig.TendermintConfigOverride,
)

cmdReader, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
}
cmd.Stderr = cmd.Stdout

if err := cmd.Start(); err != nil {
log.Fatal(err)
}

scanner := bufio.NewScanner(cmdReader)

for scanner.Scan() {
out := scanner.Text()
if verbose {
fmt.Println("startChangeover: " + out)
}
if out == done {
break
}
}
if err := scanner.Err(); err != nil {
log.Fatal("startChangeover died", err)
}
}

type AddChainToRelayerAction struct {
Chain ChainID
Validator ValidatorID
Expand Down
198 changes: 0 additions & 198 deletions tests/e2e/actions_sovereign_chain.go

This file was deleted.

Loading

0 comments on commit 530b52d

Please sign in to comment.