From 9c2d1cb306998e2261c6a4a4ed21efd978dae948 Mon Sep 17 00:00:00 2001 From: Shawn <44221603+smarshall-spitzbart@users.noreply.github.com> Date: Wed, 20 Sep 2023 10:54:47 -0700 Subject: [PATCH] consumer keeper -> provider keeper --- x/ccv/provider/keeper/migration_test.go | 60 ++++++++++++------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/x/ccv/provider/keeper/migration_test.go b/x/ccv/provider/keeper/migration_test.go index e21ac50f28..a710e3979c 100644 --- a/x/ccv/provider/keeper/migration_test.go +++ b/x/ccv/provider/keeper/migration_test.go @@ -10,50 +10,50 @@ import ( ) func TestMigrate2To3(t *testing.T) { - consumerKeeper, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) + providerKeeper, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) defer ctrl.Finish() // Set consumer client ids to mock consumers being connected to provider - consumerKeeper.SetConsumerClientId(ctx, "chain-1", "client-1") - consumerKeeper.SetConsumerClientId(ctx, "chain-2", "client-2") - consumerKeeper.SetConsumerClientId(ctx, "chain-3", "client-3") + providerKeeper.SetConsumerClientId(ctx, "chain-1", "client-1") + providerKeeper.SetConsumerClientId(ctx, "chain-2", "client-2") + providerKeeper.SetConsumerClientId(ctx, "chain-3", "client-3") // Queue some data for chain-1 - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-1", 66, testutil.GetNewSlashPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-1", 67, testutil.GetNewVSCMaturedPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-1", 68, testutil.GetNewSlashPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-1", 69, testutil.GetNewVSCMaturedPacketData()) // Queue some data for chain-2 - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-2", 789, testutil.GetNewVSCMaturedPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-2", 790, testutil.GetNewSlashPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-2", 791, testutil.GetNewVSCMaturedPacketData()) // Queue some data for chain-3 - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-3", 123, testutil.GetNewSlashPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-3", 124, testutil.GetNewVSCMaturedPacketData()) - consumerKeeper.QueueThrottledPacketDataOnlyForTesting( + providerKeeper.QueueThrottledPacketDataOnlyForTesting( ctx, "chain-3", 125, testutil.GetNewVSCMaturedPacketData()) // Confirm getter methods return expected values - slash1, vscm1 := consumerKeeper.GetAllThrottledPacketData(ctx, "chain-1") + slash1, vscm1 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-1") require.Len(t, slash1, 2) require.Len(t, vscm1, 2) - slash2, vscm2 := consumerKeeper.GetAllThrottledPacketData(ctx, "chain-2") + slash2, vscm2 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-2") require.Len(t, slash2, 1) require.Len(t, vscm2, 2) - slash3, vscm3 := consumerKeeper.GetAllThrottledPacketData(ctx, "chain-3") + slash3, vscm3 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-3") require.Len(t, slash3, 1) require.Len(t, vscm3, 2) @@ -63,55 +63,55 @@ func TestMigrate2To3(t *testing.T) { // That is, timestamp should exist before a vsc matured packet is handled, // and deleted after handling. for _, data := range vscm1 { - consumerKeeper.SetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId, time.Now()) + providerKeeper.SetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId, time.Now()) } for _, data := range vscm2 { - consumerKeeper.SetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId, time.Now()) + providerKeeper.SetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId, time.Now()) } for _, data := range vscm3 { - consumerKeeper.SetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId, time.Now()) + providerKeeper.SetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId, time.Now()) } // Confirm timestamps are set for _, data := range vscm1 { - _, found := consumerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) require.True(t, found) } for _, data := range vscm2 { - _, found := consumerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) require.True(t, found) } for _, data := range vscm3 { - _, found := consumerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) require.True(t, found) } // Run migration - err := consumerKeeper.MigrateQueuedPackets(ctx) + err := providerKeeper.MigrateQueuedPackets(ctx) require.NoError(t, err) // Confirm throttled data is now deleted - slash1, vscm1 = consumerKeeper.GetAllThrottledPacketData(ctx, "chain-1") + slash1, vscm1 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-1") require.Empty(t, slash1) require.Empty(t, vscm1) - slash2, vscm2 = consumerKeeper.GetAllThrottledPacketData(ctx, "chain-2") + slash2, vscm2 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-2") require.Empty(t, slash2) require.Empty(t, vscm2) - slash3, vscm3 = consumerKeeper.GetAllThrottledPacketData(ctx, "chain-3") + slash3, vscm3 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-3") require.Empty(t, slash3) require.Empty(t, vscm3) // Confirm timestamps are deleted, meaning vsc matured packets were handled for _, data := range vscm1 { - _, found := consumerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) require.False(t, found) } for _, data := range vscm2 { - _, found := consumerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) require.False(t, found) } for _, data := range vscm3 { - _, found := consumerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) require.False(t, found) } }