From 377a3f0f66e915b90ab8612567d6e0df8b85549b Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Oct 2024 11:16:28 +0200 Subject: [PATCH] fix!: add missing gov v5 migration section --- app/upgrades/v21/upgrades.go | 8 ++++++++ app/upgrades/v21/upgrades_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 app/upgrades/v21/upgrades_test.go diff --git a/app/upgrades/v21/upgrades.go b/app/upgrades/v21/upgrades.go index 5575045bbc..631d1c5099 100644 --- a/app/upgrades/v21/upgrades.go +++ b/app/upgrades/v21/upgrades.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/gaia/v21/app/keepers" ) @@ -29,3 +30,10 @@ func CreateUpgradeHandler( return vm, nil } } + +// setting the default constitution for the chain +// this is in line with cosmos-sdk v5 gov migration: https://github.com/cosmos/cosmos-sdk/blob/v0.50.10/x/gov/migrations/v5/store.go#L57 +func InitializeConstitutionCollection(ctx sdk.Context, govKeeper govkeeper.Keeper) error { + govKeeper.Constitution.Set(ctx, "This chain has no constitution.") + return nil +} diff --git a/app/upgrades/v21/upgrades_test.go b/app/upgrades/v21/upgrades_test.go new file mode 100644 index 0000000000..2e53a5aca5 --- /dev/null +++ b/app/upgrades/v21/upgrades_test.go @@ -0,0 +1,25 @@ +package v21_test + +import ( + "testing" + + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/gaia/v21/app/helpers" + v21 "github.com/cosmos/gaia/v21/app/upgrades/v21" + "github.com/stretchr/testify/require" +) + +func TestInitializeConstitutionCollection(t *testing.T) { + gaiaApp := helpers.Setup(t) + ctx := gaiaApp.NewUncachedContext(true, tmproto.Header{}) + + govKeeper := gaiaApp.GovKeeper + + pre, err := govKeeper.Constitution.Get(ctx) + require.NoError(t, err) + require.Equal(t, "", pre) + v21.InitializeConstitutionCollection(ctx, *govKeeper) + post, err := govKeeper.Constitution.Get(ctx) + require.NoError(t, err) + require.Equal(t, "This chain has no constitution.", post) +}