Skip to content

Commit

Permalink
fix migrate
Browse files Browse the repository at this point in the history
fix test

fix lint

test param
  • Loading branch information
mmsqe committed Sep 27, 2023
1 parent bcf4663 commit 9a2f531
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):

rsp = cli.query_params("icaauth")
assert rsp["params"]["min_timeout_duration"] == "3600s", rsp
assert cli.query_params()["max_callback_gas"] == "300000", rsp

# migrate to sdk v0.47
custom_cronos.supervisorctl("stop", "all")
Expand Down
2 changes: 1 addition & 1 deletion x/cronos/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ type (
//
// NOTE: This is used solely for migration of x/params managed parameters.
Subspace interface {
GetParamSet(ctx sdk.Context, ps ParamSet)
GetParamSetIfExists(ctx sdk.Context, ps ParamSet)
}
)
6 changes: 4 additions & 2 deletions x/cronos/migrations/v2/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import (
// module state.
func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)
legacySubspace.GetParamSetIfExists(ctx, &currParams)

if err := currParams.Validate(); err != nil {
return err
}

if currParams.GetMaxCallbackGas() == 0 {
currParams.MaxCallbackGas = types.MaxCallbackGasDefaultValue
}
bz := cdc.MustMarshal(&currParams)
store.Set(types.ParamsKey, bz)

Expand Down
2 changes: 1 addition & 1 deletion x/cronos/migrations/v2/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func newMockSubspace(ps types.Params) mockSubspace {
return mockSubspace{ps: ps}
}

func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) {
func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps exported.ParamSet) {
*ps.(*types.Params) = ms.ps
}

Expand Down

0 comments on commit 9a2f531

Please sign in to comment.