From a0528aeede7bba6284808a80fcbb8c0f35391437 Mon Sep 17 00:00:00 2001 From: Philip Offtermatt Date: Wed, 12 Jun 2024 09:41:19 +0200 Subject: [PATCH] Add test for updating minimum power in top N --- x/ccv/provider/keeper/keeper_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index f1e8a144b0..c05446fbaf 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -852,3 +852,22 @@ func TestMinimumPowerInTopN(t *testing.T) { require.False(t, found) require.Equal(t, int64(0), nonExistentMinPower) } + +func TestUpdateMinimumPowerInTopN(t *testing.T) { + k, ctx, _, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + + chainID := "testChain" + initialMinPower := int64(1000) + updatedMinPower := int64(2000) + + // Set the initial minimum power in top N + k.SetMinimumPowerInTopN(ctx, chainID, initialMinPower) + + // Update the minimum power in top N + k.SetMinimumPowerInTopN(ctx, chainID, updatedMinPower) + + // Retrieve the updated minimum power in top N + gotMinPower, found := k.GetMinimumPowerInTopN(ctx, chainID) + require.True(t, found) + require.Equal(t, updatedMinPower, gotMinPower) +}