Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: throttle retry e2e tests #1312

Merged
12 changes: 12 additions & 0 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,18 @@ func (tr TestRun) waitForSlashMeterReplenishment(
}
}

type WaitTimeAction struct {
consumer chainID
waitTime time.Duration
}

func (tr TestRun) waitForTime(
action WaitTimeAction,
verbose bool,
) {
tr.WaitTime(action.waitTime)
}

// GetPathNameForGorelayer returns the name of the path between two given chains used by Gorelayer.
// Since paths are bidirectional, we need either chain to be able to be provided as first or second argument
// and still return the same name, so we sort the chain names alphabetically.
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func SlashThrottleTestRun() TestRun {
".app_state.slashing.params.signed_blocks_window = \"15\" | " +
".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " +
".app_state.slashing.params.downtime_jail_duration = \"60s\" | " +
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"",
".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " +
".app_state.ccvconsumer.params.retry_delay_period = \"30s\"",
},
},
tendermintConfigOverride: `s/timeout_commit = "5s"/timeout_commit = "1s"/;` +
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) {
tr.assignConsumerPubKey(action, verbose)
case slashMeterReplenishmentAction:
tr.waitForSlashMeterReplenishment(action, verbose)
case WaitTimeAction:
tr.waitForTime(action, verbose)
case startRelayerAction:
tr.startRelayer(action, verbose)
case registerConsumerRewardDenomAction:
Expand Down
46 changes: 44 additions & 2 deletions tests/e2e/steps_downtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ func stepsThrottledDowntime(consumerName string) []Step {
},
},
},
// Relay slash packet to provider, and ack back to consumer
{
action: relayPacketsAction{
chainA: chainID("provi"),
Expand All @@ -375,8 +376,6 @@ func stepsThrottledDowntime(consumerName string) []Step {
},
},
},
// TODO(Shawn): Improve this test to have the consumer retry it's downtime slash, and to assert queue size on consumer.
// See https://github.com/cosmos/interchain-security/issues/1103 and https://github.com/cosmos/interchain-security/issues/1233
{
action: slashMeterReplenishmentAction{
targetValue: 0, // We just want slash meter to be non-negative
Expand All @@ -401,6 +400,49 @@ func stepsThrottledDowntime(consumerName string) []Step {
validatorID("bob"): 0,
validatorID("carol"): 500,
},
ConsumerPendingPacketQueueSize: uintPtr(1), // packet still queued
},
},
},
// Wait for retry delay period to pass.
// Retry delay period is set to 30 seconds, see config.go,
// wait this amount of time to elapse the period.
{
action: WaitTimeAction{
consumer: chainID(consumerName),
waitTime: 30 * time.Second,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 0,
validatorID("carol"): 500,
},
},
chainID(consumerName): ChainState{
ConsumerPendingPacketQueueSize: uintPtr(1), // packet still queued
},
},
},
// Relay now that retry delay period has passed, confirm provider applies jailing
{
action: relayPacketsAction{
chainA: chainID("provi"),
chainB: chainID(consumerName),
port: "provider",
channel: 0,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 0,
validatorID("carol"): 0, // jailed!
},
},
chainID(consumerName): ChainState{
ConsumerPendingPacketQueueSize: uintPtr(0), // relayed slash packet handled ack clears consumer queue
},
},
},
Expand Down