-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* chore: adding channel params migration * chore: removed separate migration fn * chore: fix linter * chore: bump consensus * chore: fix linter again * chore: pr feedback --------- Co-authored-by: Carlos Rodriguez <carlos@interchain.io> (cherry picked from commit 59ac9b2) Co-authored-by: Cian Hatton <cian@interchain.io>
- Loading branch information
1 parent
73ddc6d
commit 5959b27
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
) | ||
|
||
// Migrator is a struct for handling in-place store migrations. | ||
type Migrator struct { | ||
keeper Keeper | ||
} | ||
|
||
// NewMigrator returns a new Migrator. | ||
func NewMigrator(keeper Keeper) Migrator { | ||
return Migrator{keeper: keeper} | ||
} | ||
|
||
// MigrateParams migrates params to the default channel params. | ||
func (m Migrator) MigrateParams(ctx sdk.Context) error { | ||
params := channeltypes.DefaultParams() | ||
m.keeper.SetParams(ctx, params) | ||
m.keeper.Logger(ctx).Info("successfully migrated ibc channel params") | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper" | ||
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
) | ||
|
||
// TestMigrateDefaultParams tests the migration for the channel params | ||
func (suite *KeeperTestSuite) TestMigrateDefaultParams() { | ||
testCases := []struct { | ||
name string | ||
expectedParams channeltypes.Params | ||
}{ | ||
{ | ||
"success: default params", | ||
channeltypes.DefaultParams(), | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
suite.Run(tc.name, func() { | ||
suite.SetupTest() // reset | ||
|
||
ctx := suite.chainA.GetContext() | ||
migrator := keeper.NewMigrator(suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper) | ||
err := migrator.MigrateParams(ctx) | ||
suite.Require().NoError(err) | ||
|
||
params := suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.GetParams(ctx) | ||
suite.Require().Equal(tc.expectedParams, params) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters