Skip to content

Commit

Permalink
Add e2e test for inactive vals
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jun 27, 2024
1 parent 49a6e04 commit cc1185d
Show file tree
Hide file tree
Showing 4 changed files with 545 additions and 4 deletions.
26 changes: 25 additions & 1 deletion tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const (
ConsumerMisbehaviourTestCfg TestConfigType = "consumer-misbehaviour"
CompatibilityTestCfg TestConfigType = "compatibility"
SmallMaxValidatorsTestCfg TestConfigType = "small-max-validators"
InactiveProviderValsTestCfg TestConfigType = "inactive-provider-vals"
)

type TestConfig struct {
Expand Down Expand Up @@ -180,6 +181,8 @@ func GetTestConfig(cfgType TestConfigType, providerVersion, consumerVersion stri
testCfg = CompatibilityTestConfig(pv, cv)
case SmallMaxValidatorsTestCfg:
testCfg = SmallMaxValidatorsTestConfig()
case InactiveProviderValsTestCfg:
testCfg = InactiveProviderValsTestConfig()
default:
panic(fmt.Sprintf("Invalid test config: %s", cfgType))
}
Expand Down Expand Up @@ -417,7 +420,7 @@ func CompatibilityTestConfig(providerVersion, consumerVersion string) TestConfig
".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\" | " + // This disables slash packet throttling
".app_state.provider.params.slash_meter_replenish_period = \"3s\"",
}
} else if semver.Compare(providerVersion, "v5.0.0-alpha1") < 0 { //TODO: MOV THIS BACK TO "v5.0.0"
} else if semver.Compare(providerVersion, "v5.0.0-alpha1") < 0 { // TODO: MOV THIS BACK TO "v5.0.0"
fmt.Println("Using provider chain config for v4.1.x")
providerConfig = ChainConfig{
ChainId: ChainID("provi"),
Expand Down Expand Up @@ -557,6 +560,27 @@ func DemocracyTestConfig(allowReward bool) TestConfig {
return tr
}

func InactiveProviderValsTestConfig() TestConfig {
tr := DefaultTestConfig()
tr.name = "InactiveValsConfig"
// set the MaxProviderConsensusValidators param to 2
proviConfig := tr.chainConfigs[ChainID("provi")]
proviConfig.GenesisChanges += " | .app_state.provider.params.max_provider_consensus_validators = \"2\""

consuConfig := tr.chainConfigs[ChainID("consu")]
// set the soft_opt_out threshold to 0% to make sure all validators are slashed for downtime
consuConfig.GenesisChanges += " | .app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.0\""
tr.chainConfigs[ChainID("provi")] = proviConfig
tr.chainConfigs[ChainID("consu")] = consuConfig

// make is to that carol does not use a consumer key
carolConfig := tr.validatorConfigs[ValidatorID("carol")]
carolConfig.UseConsumerKey = false
tr.validatorConfigs[ValidatorID("carol")] = carolConfig

return tr
}

func SmallMaxValidatorsTestConfig() TestConfig {
cfg := DefaultTestConfig()

Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ var stepChoices = map[string]StepChoice{
description: "This is a regression test related to the issue discussed here: https://forum.cosmos.network/t/cosmos-hub-v17-1-chain-halt-post-mortem/13899. The test ensures that the protocol works as expected when MaxValidators is smaller than the number of potential validators.",
testConfig: SmallMaxValidatorsTestCfg,
},
"inactive-provider-validators-on-consumer": {
name: "inactive-provider-validators-on-consumer",
steps: stepsInactiveProviderValidators(),
description: "test inactive validators on consumer",
testConfig: InactiveProviderValsTestCfg,
},
}

func getTestCaseUsageString() string {
Expand Down
10 changes: 7 additions & 3 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,18 @@ func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight u
binaryName := tr.chainConfigs[chain].BinaryName
cmd := tr.target.ExecCommand(binaryName,
"query", "distribution", "delegation-total-rewards",
"--delegator-address", delAddresss,
delAddresss,
`--height`, fmt.Sprint(blockHeight),
`--node`, tr.GetQueryNode(chain),
`-o`, `json`,
)

bz, err := cmd.CombinedOutput()
if *verbose {
log.Println("getting rewards for chain: ", chain, " validator: ", validator, " blockHeight: ", blockHeight)
log.Println(cmd)
}

bz, err := cmd.CombinedOutput()
if err != nil {
log.Fatal("failed getting rewards: ", err, "\n", string(bz))
}
Expand All @@ -380,7 +384,7 @@ func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight u

// interchain-securityd query gov proposals
func (tr Commands) GetProposal(chain ChainID, proposal uint) Proposal {
var noProposalRegex = regexp.MustCompile(`doesn't exist: key not found`)
noProposalRegex := regexp.MustCompile(`doesn't exist: key not found`)

binaryName := tr.chainConfigs[chain].BinaryName
bz, err := tr.target.ExecCommand(binaryName,
Expand Down
Loading

0 comments on commit cc1185d

Please sign in to comment.