-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: introduce v4 provider migration code (#1762)
(cherry picked from commit 15d2d21)
- Loading branch information
1 parent
9de8555
commit bdd8807
Showing
6 changed files
with
54 additions
and
31 deletions.
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
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
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
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,27 @@ | ||
package v4 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
testutil "github.com/cosmos/interchain-security/v4/testutil/keeper" | ||
providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" | ||
) | ||
|
||
func TestMigrateParams(t *testing.T) { | ||
inMemParams := testutil.NewInMemKeeperParams(t) | ||
_, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, inMemParams) | ||
defer ctrl.Finish() | ||
|
||
// initially blocks per epoch param does not exist | ||
require.False(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyBlocksPerEpoch)) | ||
|
||
MigrateParams(ctx, *inMemParams.ParamsSubspace) | ||
|
||
// after migration, blocks per epoch param should exist and be equal to default | ||
require.True(t, inMemParams.ParamsSubspace.Has(ctx, providertypes.KeyBlocksPerEpoch)) | ||
var blocksPerEpochParam int64 | ||
inMemParams.ParamsSubspace.Get(ctx, providertypes.KeyBlocksPerEpoch, &blocksPerEpochParam) | ||
require.Equal(t, providertypes.DefaultBlocksPerEpoch, blocksPerEpochParam) | ||
} |
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,18 @@ | ||
package v4 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
providertypes "github.com/cosmos/interchain-security/v4/x/ccv/provider/types" | ||
) | ||
|
||
// MigrateParams adds missing provider chain params to the param store. | ||
func MigrateParams(ctx sdk.Context, paramsSubspace paramtypes.Subspace) { | ||
if paramsSubspace.HasKeyTable() { | ||
paramsSubspace.Set(ctx, providertypes.KeyBlocksPerEpoch, providertypes.DefaultBlocksPerEpoch) | ||
} else { | ||
paramsSubspace.WithKeyTable(providertypes.ParamKeyTable()) | ||
paramsSubspace.Set(ctx, providertypes.KeyBlocksPerEpoch, providertypes.DefaultBlocksPerEpoch) | ||
} | ||
} |
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