From c15fddecdcd5750f6481e104f3564f614d7dddc5 Mon Sep 17 00:00:00 2001 From: Bernd Mueller Date: Fri, 30 Aug 2024 14:44:47 +0200 Subject: [PATCH] adapt unit-tests --- testutil/keeper/unit_test_helpers.go | 11 ++++++++--- x/ccv/provider/keeper/proposal_test.go | 2 +- x/ccv/provider/keeper/relay_test.go | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index 95c5de2380..584c6a0633 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -247,7 +247,7 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, // TestProviderStateIsCleanedAfterConsumerChainIsStopped executes test assertions for the provider's state being cleaned // after a stopped consumer chain. func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, - consumerId, expectedChannelID string, + consumerId, expectedChannelID string, expErr bool, ) { t.Helper() _, found := providerKeeper.GetConsumerClientId(ctx, consumerId) @@ -262,8 +262,13 @@ func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk require.Empty(t, acks) // in case the chain was successfully stopped, it should not contain a Top N associated to it - _, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) - require.Error(t, err) + ps, err := providerKeeper.GetConsumerPowerShapingParameters(ctx, consumerId) + if expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + require.Empty(t, ps) // test key assignment state is cleaned require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &consumerId)) diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index 9e5e094eb2..f33978a8d5 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -172,7 +172,7 @@ func TestStopConsumerChain(t *testing.T) { require.NoError(t, err) } - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, consumerId, "channelID", tc.expErr) ctrl.Finish() } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index fb27247263..9367a944a6 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -542,7 +542,7 @@ func TestOnTimeoutPacketStopsChain(t *testing.T) { } err := providerKeeper.OnTimeoutPacket(ctx, packet) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false) require.NoError(t, err) } @@ -578,7 +578,7 @@ func TestOnAcknowledgementPacketWithAckError(t *testing.T) { err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError) - testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "consumerId", "channelID", false) require.NoError(t, err) }