Skip to content

Commit

Permalink
fix e2e test 'ConsumerModificationProposal'
Browse files Browse the repository at this point in the history
  • Loading branch information
bermuell committed Jun 12, 2024
1 parent 621c759 commit 41bbba2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 116 deletions.
20 changes: 12 additions & 8 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,14 @@ type SubmitConsumerModificationProposalAction struct {
Denylist []string
}

func (tr TestConfig) submitConsumerModificationProposal(
func (tr Chain) submitConsumerModificationProposal(
action SubmitConsumerModificationProposalAction,
target ExecutionTarget,
verbose bool,
) {
prop := client.ConsumerModificationProposalJSON{
Title: "Propose the modification of the PSS parameters of a chain",
Summary: "summary of a modification proposal",
ChainId: string(tr.chainConfigs[action.ConsumerChain].ChainId),
ChainId: string(tr.testConfig.chainConfigs[action.ConsumerChain].ChainId),
Deposit: fmt.Sprint(action.Deposit) + `stake`,
TopN: action.TopN,
ValidatorsPowerCap: action.ValidatorsPowerCap,
Expand All @@ -444,19 +443,19 @@ func (tr TestConfig) submitConsumerModificationProposal(
}

//#nosec G204 -- bypass unsafe quoting warning (no production code)
bz, err = target.ExecCommand(
bz, err = tr.target.ExecCommand(
"/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json"),
).CombinedOutput()
if err != nil {
log.Fatal(err, "\n", string(bz))
}

// CONSUMER MODIFICATION PROPOSAL
cmd := target.ExecCommand(
tr.chainConfigs[action.Chain].BinaryName,
cmd := tr.target.ExecCommand(
tr.testConfig.chainConfigs[action.Chain].BinaryName,
"tx", "gov", "submit-legacy-proposal", "consumer-modification", "/temp-proposal.json",
`--from`, `validator`+fmt.Sprint(action.From),
`--chain-id`, string(tr.chainConfigs[action.Chain].ChainId),
`--chain-id`, string(tr.testConfig.chainConfigs[action.Chain].ChainId),
`--home`, tr.getValidatorHome(action.Chain, action.From),
`--gas`, `900000`,
`--node`, tr.getValidatorNode(action.Chain, action.From),
Expand All @@ -465,6 +464,7 @@ func (tr TestConfig) submitConsumerModificationProposal(
)
if verbose {
log.Println("submitConsumerModificationProposal cmd: ", cmd.String())
log.Println("submitConsumerModificationProposal json: ", jsonStr)
}

bz, err = cmd.CombinedOutput()
Expand All @@ -473,6 +473,10 @@ func (tr TestConfig) submitConsumerModificationProposal(
log.Fatal(err, "\n", string(bz))
}

if verbose {
log.Println("submitConsumerModificationProposal output: ", string(bz))
}

// wait for inclusion in a block -> '--broadcast-mode block' is deprecated
tr.waitBlocks(ChainID("provi"), 2, 10*time.Second)
}
Expand All @@ -488,7 +492,7 @@ func (tr Chain) submitEnableTransfersProposalAction(
action SubmitEnableTransfersProposalAction,
verbose bool,
) {
// gov signed addres got by checking the gov module acc address in the test container
// gov signed address got by checking the gov module acc address in the test container
// interchain-security-cdd q auth module-account gov --node tcp://7.7.9.253:26658
template := `
{
Expand Down
107 changes: 14 additions & 93 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ import (

// type aliases
type (
ChainState = e2e.ChainState
Proposal = e2e.Proposal
Rewards = e2e.Rewards
TextProposal = e2e.TextProposal
UpgradeProposal = e2e.UpgradeProposal
ConsumerAdditionProposal = e2e.ConsumerAdditionProposal
ConsumerRemovalProposal = e2e.ConsumerRemovalProposal
IBCTransferParams = e2e.IBCTransferParams
IBCTransferParamsProposal = e2e.IBCTransferParamsProposal
Param = e2e.Param
ParamsProposal = e2e.ParamsProposal
TargetDriver = e2e.TargetDriver
ChainState = e2e.ChainState
Proposal = e2e.Proposal
Rewards = e2e.Rewards
TextProposal = e2e.TextProposal
UpgradeProposal = e2e.UpgradeProposal
ConsumerAdditionProposal = e2e.ConsumerAdditionProposal
ConsumerRemovalProposal = e2e.ConsumerRemovalProposal
ConsumerModificationProposal = e2e.ConsumerModificationProposal
IBCTransferParams = e2e.IBCTransferParams
IBCTransferParamsProposal = e2e.IBCTransferParamsProposal
Param = e2e.Param
ParamsProposal = e2e.ParamsProposal
TargetDriver = e2e.TargetDriver
)

type State map[ChainID]ChainState
Expand All @@ -41,86 +42,6 @@ type Chain struct {
}

func (tr Chain) GetChainState(chain ChainID, modelState ChainState) ChainState {

func (p TextProposal) isProposal() {}

type ConsumerAdditionProposal struct {
Deposit uint
Chain ChainID
SpawnTime int
InitialHeight clienttypes.Height
Status string
}

type UpgradeProposal struct {
Title string
Description string
UpgradeHeight uint64
Type string
Deposit uint
Status string
}

func (p UpgradeProposal) isProposal() {}

func (p ConsumerAdditionProposal) isProposal() {}

type ConsumerRemovalProposal struct {
Deposit uint
Chain ChainID
StopTime int
Status string
}

func (p ConsumerRemovalProposal) isProposal() {}

type ConsumerModificationProposal struct {
Deposit uint
Chain ChainID
Status string
}

func (p ConsumerModificationProposal) isProposal() {}

type Rewards struct {
IsRewarded map[ValidatorID]bool
// if true it will calculate if the validator/delegator is rewarded between 2 successive blocks,
// otherwise it will calculate if it received any rewards since the 1st block
IsIncrementalReward bool
// if true checks rewards for "stake" token, otherwise checks rewards from
// other chains (e.g. false is used to check if provider received rewards from a consumer chain)
IsNativeDenom bool
}

type ParamsProposal struct {
Deposit uint
Status string
Subspace string
Key string
Value string
}

func (p ParamsProposal) isProposal() {}

type Param struct {
Subspace string
Key string
Value string
}

func (tr TestConfig) getState(modelState State, verbose bool) State {
systemState := State{}
for k, modelState := range modelState {
if verbose {
fmt.Println("Getting model state for chain: ", k)
}
systemState[k] = tr.getChainState(k, modelState)
}

return systemState
}

func (tr TestConfig) getChainState(chain ChainID, modelState ChainState) ChainState {
chainState := ChainState{}

if modelState.ValBalances != nil {
Expand Down Expand Up @@ -568,7 +489,7 @@ func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal {
}

case "/interchain_security.ccv.provider.v1.ConsumerModificationProposal":
chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String()
chainId := rawContent.Get("chain_id").String()

var chain ChainID
for i, conf := range tr.chainConfigs {
Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/steps_partial_set_security.go
Original file line number Diff line number Diff line change
Expand Up @@ -1939,7 +1939,7 @@ func stepsModifyChain() []Step {
Chain: ChainID("consu"),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
HasToValidate: &map[ValidatorID][]ChainID{
Expand Down Expand Up @@ -2024,7 +2024,7 @@ func stepsModifyChain() []Step {
Chain: ChainID("consu"),
SpawnTime: 0,
InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1},
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
},
Expand Down Expand Up @@ -2123,7 +2123,7 @@ func stepsModifyChain() []Step {
2: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -2142,7 +2142,7 @@ func stepsModifyChain() []Step {
2: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
},
Expand Down Expand Up @@ -2189,7 +2189,7 @@ func stepsModifyChain() []Step {
3: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -2208,7 +2208,7 @@ func stepsModifyChain() []Step {
3: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
},
Expand Down Expand Up @@ -2258,7 +2258,7 @@ func stepsModifyChain() []Step {
4: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -2277,7 +2277,7 @@ func stepsModifyChain() []Step {
4: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
},
Expand Down Expand Up @@ -2324,7 +2324,7 @@ func stepsModifyChain() []Step {
5: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -2343,7 +2343,7 @@ func stepsModifyChain() []Step {
5: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
},
Expand Down Expand Up @@ -2389,7 +2389,7 @@ func stepsModifyChain() []Step {
6: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_VOTING_PERIOD",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_VOTING_PERIOD)),
},
},
},
Expand All @@ -2408,7 +2408,7 @@ func stepsModifyChain() []Step {
6: ConsumerModificationProposal{
Deposit: 10000001,
Chain: ChainID("consu"),
Status: "PROPOSAL_STATUS_PASSED",
Status: strconv.Itoa(int(gov.ProposalStatus_PROPOSAL_STATUS_PASSED)),
},
},
},
Expand Down
4 changes: 1 addition & 3 deletions tests/e2e/test_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ func (td *DefaultDriver) runAction(action interface{}) error {
case SubmitEnableTransfersProposalAction:
target.submitEnableTransfersProposalAction(action, td.verbose)
case SubmitConsumerModificationProposalAction:
target.submitConsumerModificationProposal(action, td.target, td.verbose) //FIXME BERND
case SubmitParamChangeLegacyProposalAction:
target.submitParamChangeProposal(action, td.target, td.verbose) //FIXME BERND
target.submitConsumerModificationProposal(action, td.verbose)
case VoteGovProposalAction:
target.voteGovProposal(action, td.verbose)
case StartConsumerChainAction:
Expand Down
8 changes: 8 additions & 0 deletions tests/e2e/testlib/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ type ConsumerRemovalProposal struct {

func (p ConsumerRemovalProposal) isProposal() {}

type ConsumerModificationProposal struct {
Deposit uint
Chain ChainID
Status string
}

func (p ConsumerModificationProposal) isProposal() {}

type Rewards struct {
IsRewarded map[ValidatorID]bool
// if true it will calculate if the validator/delegator is rewarded between 2 successive blocks,
Expand Down

0 comments on commit 41bbba2

Please sign in to comment.