Skip to content

Commit

Permalink
add upgrades test, add remove todos, fix param space
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 15, 2024
1 parent 1f700dd commit b957ff9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
11 changes: 11 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}

0 comments on commit b957ff9

Please sign in to comment.