From a0b1e5e11b13d550a9220efebfb28d7e32d72cb0 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 19 Sep 2023 09:51:06 -0700 Subject: [PATCH] tests: throttle retry e2e tests (#1312) * boilerplate * fix test * Update proposal_test.go * apply new param to keeper code * wip * add action * incorporate queue assertions. Also make retry delay period 200s * correct queue size assertion * make wait time just 30 seconds * change naming --- tests/e2e/actions.go | 12 ++++++++++ tests/e2e/config.go | 3 ++- tests/e2e/main.go | 2 ++ tests/e2e/steps_downtime.go | 46 +++++++++++++++++++++++++++++++++++-- 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 7f31a3b451..b2614c4e5e 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -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. diff --git a/tests/e2e/config.go b/tests/e2e/config.go index 373281162d..093e32de81 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -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"/;` + diff --git a/tests/e2e/main.go b/tests/e2e/main.go index c8a840f206..e6a8f7489b 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -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: diff --git a/tests/e2e/steps_downtime.go b/tests/e2e/steps_downtime.go index d5f994879c..36a9716125 100644 --- a/tests/e2e/steps_downtime.go +++ b/tests/e2e/steps_downtime.go @@ -350,6 +350,7 @@ func stepsThrottledDowntime(consumerName string) []Step { }, }, }, + // Relay slash packet to provider, and ack back to consumer { action: relayPacketsAction{ chainA: chainID("provi"), @@ -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 @@ -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 }, }, },