From 0d0709c6c9061f0c1ed81495cc321a1ff8a28cf8 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Tue, 26 Sep 2023 14:07:10 -0700 Subject: [PATCH] action boilerplate --- tests/e2e/action_rapid_test.go | 23 +++++++++++++++-------- tests/e2e/json_utils.go | 10 ++++++++-- tests/e2e/state_rapid_test.go | 12 +++++------- 3 files changed, 28 insertions(+), 17 deletions(-) diff --git a/tests/e2e/action_rapid_test.go b/tests/e2e/action_rapid_test.go index 005f52610d..09d28abacf 100644 --- a/tests/e2e/action_rapid_test.go +++ b/tests/e2e/action_rapid_test.go @@ -84,8 +84,9 @@ func GetActionGen() *rapid.Generator[any] { GetRegisterRepresentativeActionGen().AsAny(), GetDoublesignSlashActionGen().AsAny(), GetAssignConsumerPubKeyActionGen().AsAny(), - GetSlashThrottleDequeueActionGen().AsAny(), GetCreateIbcClientsActionGen().AsAny(), + GetSlashMeterReplenishmentAction().AsAny(), + GetWaitTimeAction().AsAny(), CreateCancelUnbondTokensActionGen().AsAny(), CreateLightClientEquivocationAttackActionGen().AsAny(), CreateLightClientAmnesiaAttackActionGen().AsAny(), @@ -489,13 +490,19 @@ func GetAssignConsumerPubKeyActionGen() *rapid.Generator[assignConsumerPubKeyAct }) } -func GetSlashThrottleDequeueActionGen() *rapid.Generator[slashThrottleDequeueAction] { - return rapid.Custom(func(t *rapid.T) slashThrottleDequeueAction { - return slashThrottleDequeueAction{ - Chain: GetChainIDGen().Draw(t, "Chain"), - CurrentQueueSize: rapid.Int().Draw(t, "CurrentQueueSize"), - NextQueueSize: rapid.Int().Draw(t, "NextQueueSize"), - Timeout: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, +func GetSlashMeterReplenishmentAction() *rapid.Generator[slashMeterReplenishmentAction] { + return rapid.Custom(func(t *rapid.T) slashMeterReplenishmentAction { + return slashMeterReplenishmentAction{ + TargetValue: rapid.Int64().Draw(t, "TargetValue"), + Timeout: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, + } + }) +} + +func GetWaitTimeAction() *rapid.Generator[waitTimeAction] { + return rapid.Custom(func(t *rapid.T) waitTimeAction { + return waitTimeAction{ + WaitTime: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, } }) } diff --git a/tests/e2e/json_utils.go b/tests/e2e/json_utils.go index 692c34a14f..3d5867d42a 100644 --- a/tests/e2e/json_utils.go +++ b/tests/e2e/json_utils.go @@ -221,8 +221,14 @@ func UnmarshalMapToActionType(rawAction json.RawMessage, actionTypeString string if err == nil { return a, nil } - case "main.slashThrottleDequeueAction": - var a slashThrottleDequeueAction + case "main.slashMeterReplenishmentAction": + var a slashMeterReplenishmentAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.waitTimeAction": + var a waitTimeAction err := json.Unmarshal(rawAction, &a) if err == nil { return a, nil diff --git a/tests/e2e/state_rapid_test.go b/tests/e2e/state_rapid_test.go index 6c82c2e7fb..fd7fe20459 100644 --- a/tests/e2e/state_rapid_test.go +++ b/tests/e2e/state_rapid_test.go @@ -45,8 +45,7 @@ func GetChainStateGen() *rapid.Generator[ChainState] { consumerChains := GetConsumerChainsGen().Draw(t, "ConsumerChains") assignedKeys := GetAssignedKeysGen().Draw(t, "AssignedKeys") providerKeys := GetProviderKeysGen().Draw(t, "ProviderKeys") - consumerChainQueueSizes := GetConsumerChainQueueSizesGen().Draw(t, "ConsumerChainQueueSizes") - globalSlashQueueSize := rapid.Uint().Draw(t, "GlobalSlashQueueSize") + consumerPacketQueueSize := GetConsumerChainQueueSizesGen().Draw(t, "ConsumerChainQueueSizes") registeredConsumerRewardDenoms := GetRegisteredConsumerRewardDenomsGen().Draw(t, "RegisteredConsumerRewardDenoms") return ChainState{ @@ -59,8 +58,7 @@ func GetChainStateGen() *rapid.Generator[ChainState] { ConsumerChains: &consumerChains, AssignedKeys: &assignedKeys, ProviderKeys: &providerKeys, - ConsumerChainQueueSizes: &consumerChainQueueSizes, - GlobalSlashQueueSize: &globalSlashQueueSize, + ConsumerPendingPacketQueueSize: &consumerPacketQueueSize, RegisteredConsumerRewardDenoms: ®isteredConsumerRewardDenoms, } }) @@ -72,9 +70,9 @@ func GetRegisteredConsumerRewardDenomsGen() *rapid.Generator[[]string] { }) } -func GetConsumerChainQueueSizesGen() *rapid.Generator[map[ChainID]uint] { - return rapid.Custom(func(t *rapid.T) map[ChainID]uint { - return rapid.MapOf(GetChainIDGen(), rapid.Uint()).Draw(t, "ConsumerChainQueueSizes") +func GetConsumerChainQueueSizesGen() *rapid.Generator[uint] { + return rapid.Custom(func(t *rapid.T) uint { + return rapid.Uint().Draw(t, "ConsumerChainQueueSizes") }) }