Skip to content

Commit

Permalink
fix!: add missing gov v5 migration section
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalopek committed Oct 3, 2024
1 parent 7f16da6 commit 377a3f0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/upgrades/v21/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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.")

Check failure on line 37 in app/upgrades/v21/upgrades.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `govKeeper.Constitution.Set` is not checked (errcheck)

Check failure on line 37 in app/upgrades/v21/upgrades.go

View workflow job for this annotation

GitHub Actions / Analyze

Error return value of `govKeeper.Constitution.Set` is not checked (errcheck)
return nil
}
25 changes: 25 additions & 0 deletions app/upgrades/v21/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -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)

Check failure on line 21 in app/upgrades/v21/upgrades_test.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `v21.InitializeConstitutionCollection` is not checked (errcheck)

Check failure on line 21 in app/upgrades/v21/upgrades_test.go

View workflow job for this annotation

GitHub Actions / Analyze

Error return value of `v21.InitializeConstitutionCollection` is not checked (errcheck)
post, err := govKeeper.Constitution.Get(ctx)
require.NoError(t, err)
require.Equal(t, "This chain has no constitution.", post)
}

0 comments on commit 377a3f0

Please sign in to comment.