diff --git a/modules/core/02-client/migrations/v7/store.go b/modules/core/02-client/migrations/v7/store.go index 20cb2ee2fd0..7d7d6c9cb15 100644 --- a/modules/core/02-client/migrations/v7/store.go +++ b/modules/core/02-client/migrations/v7/store.go @@ -91,6 +91,10 @@ func handleTendermintMigration(ctx sdk.Context, store sdk.KVStore, cdc codec.Bin return err } + if len(clients) == 0 { + return nil // no-op if no tm clients exist + } + if len(clients) > 1 { return sdkerrors.Wrap(sdkerrors.ErrLogic, "more than one Tendermint client collected") } diff --git a/modules/core/02-client/migrations/v7/store_test.go b/modules/core/02-client/migrations/v7/store_test.go index 006ab637531..e0c2ad35d17 100644 --- a/modules/core/02-client/migrations/v7/store_test.go +++ b/modules/core/02-client/migrations/v7/store_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/v6/modules/core/02-client/migrations/v7" + v7 "github.com/cosmos/ibc-go/v6/modules/core/02-client/migrations/v7" "github.com/cosmos/ibc-go/v6/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v6/testing" @@ -65,6 +65,22 @@ func (suite *MigrationsV7TestSuite) TestMigrateStore() { suite.assertNoLocalhostClients() } +func (suite *MigrationsV7TestSuite) TestMigrateStoreNoTendermintClients() { + solomachines := []*ibctesting.Solomachine{ + ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1), + ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4), + } + + suite.createSolomachineClients(solomachines) + suite.createLocalhostClients() + + err := v7.MigrateStore(suite.chainA.GetContext(), suite.chainA.GetSimApp().GetKey(host.StoreKey), suite.chainA.App.AppCodec(), suite.chainA.GetSimApp().IBCKeeper.ClientKeeper) + suite.Require().NoError(err) + + suite.assertSolomachineClients(solomachines) + suite.assertNoLocalhostClients() +} + func (suite *MigrationsV7TestSuite) createSolomachineClients(solomachines []*ibctesting.Solomachine) { // manually generate old protobuf definitions and set in store // NOTE: we cannot use 'CreateClient' and 'UpdateClient' functions since we are