diff --git a/app/upgrades.go b/app/upgrades.go index b6c7ae1845..9cc8dc05ff 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -56,6 +56,8 @@ var upgrades = map[string]appUpgrade{ return nil, err } + migrateAttributeParams(ctx, app) + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err @@ -86,6 +88,8 @@ var upgrades = map[string]appUpgrade{ return nil, err } + migrateAttributeParams(ctx, app) + vm, err = runModuleMigrations(ctx, app, vm) if err != nil { return nil, err @@ -287,8 +291,9 @@ func migrateBaseappParams(ctx sdk.Context, app *App) error { // migrateAttributeParams migrates to new Attribute Params store // TODO: Remove with the umber handlers. func migrateAttributeParams(ctx sdk.Context, app *App) { - attributeParamSpace := app.ParamsKeeper.Subspace(attributetypes.ModuleName) - maxValueLength := attributetypes.DefaultMaxValueLength + attributeParamSpace := app.GetSubspace(attributetypes.ModuleName) + maxValueLength := uint32(attributetypes.DefaultMaxValueLength) + // TODO: remove attributetypes.ParamStoreKeyMaxValueLength with the umber handlers. if attributeParamSpace.Has(ctx, attributetypes.ParamStoreKeyMaxValueLength) { attributeParamSpace.Get(ctx, attributetypes.ParamStoreKeyMaxValueLength, &maxValueLength) } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 96495d8e2a..6aea033afe 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -23,6 +23,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/provenance-io/provenance/internal/helpers" + attributetypes "github.com/provenance-io/provenance/x/attribute/types" ) type UpgradeTestSuite struct { @@ -620,3 +621,13 @@ func (s *UpgradeTestSuite) TestRemoveInactiveValidatorDelegations() { s.Assert().Len(validators, 3, "GetAllValidators after %s", runnerName) }) } + +func (s *UpgradeTestSuite) TestMigrateAttributeParams() { + expectedValueLength := uint32(512) + s.app.GetSubspace(attributetypes.ModuleName).SetParamSet(s.ctx, &attributetypes.Params{MaxValueLength: expectedValueLength}) + + migrateAttributeParams(s.ctx, s.app) + + params := s.app.AttributeKeeper.GetParams(s.ctx) + s.Require().Equal(expectedValueLength, params.MaxValueLength, "GetParams() MaxValueLength should match the pre-set value") +}