Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updating 09-localhost migration code to v7 #2392

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v5
package v7

import (
"strings"
Expand All @@ -15,8 +15,8 @@ import (
// for the localhost client.
const Localhost string = "09-localhost"

// MigrateToV5 prunes the 09-Localhost client and associated consensus states from the ibc store
func MigrateToV5(ctx sdk.Context, clientKeeper clientkeeper.Keeper) {
// MigrateToV7 prunes the 09-Localhost client and associated consensus states from the ibc store
func MigrateToV7(ctx sdk.Context, clientKeeper clientkeeper.Keeper) {
clientStore := clientKeeper.ClientStore(ctx, Localhost)

iterator := sdk.KVStorePrefixIterator(clientStore, []byte(host.KeyConsensusStatePrefix))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v5_test
package v7_test

import (
"testing"
Expand All @@ -9,11 +9,11 @@ import (
clienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
host "github.com/cosmos/ibc-go/v6/modules/core/24-host"
"github.com/cosmos/ibc-go/v6/modules/core/exported"
v5 "github.com/cosmos/ibc-go/v6/modules/core/migrations/v5"
v7 "github.com/cosmos/ibc-go/v6/modules/core/migrations/v7"
ibctesting "github.com/cosmos/ibc-go/v6/testing"
)

type MigrationsV5TestSuite struct {
type MigrationsV7TestSuite struct {
suite.Suite

coordinator *ibctesting.Coordinator
Expand All @@ -22,18 +22,18 @@ type MigrationsV5TestSuite struct {
chainB *ibctesting.TestChain
}

func (suite *MigrationsV5TestSuite) SetupTest() {
func (suite *MigrationsV7TestSuite) SetupTest() {
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2)

suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))
}

func TestIBCTestSuite(t *testing.T) {
suite.Run(t, new(MigrationsV5TestSuite))
suite.Run(t, new(MigrationsV7TestSuite))
}

func (suite *MigrationsV5TestSuite) TestMigrateToV5() {
func (suite *MigrationsV7TestSuite) TestMigrateToV7() {
var clientStore sdk.KVStore

testCases := []struct {
Expand Down Expand Up @@ -92,11 +92,11 @@ func (suite *MigrationsV5TestSuite) TestMigrateToV5() {
suite.SetupTest() // reset

ctx := suite.chainA.GetContext()
clientStore = suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), v5.Localhost)
clientStore = suite.chainA.GetSimApp().IBCKeeper.ClientKeeper.ClientStore(suite.chainA.GetContext(), v7.Localhost)

tc.malleate()

v5.MigrateToV5(ctx, suite.chainA.GetSimApp().IBCKeeper.ClientKeeper)
v7.MigrateToV7(ctx, suite.chainA.GetSimApp().IBCKeeper.ClientKeeper)

if tc.expPass {
suite.Require().False(clientStore.Has(host.ClientStateKey()))
Expand Down