Skip to content

Commit

Permalink
add testnet upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
dimiandre committed Mar 9, 2024
1 parent 22b1b44 commit 5e11005
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import (
testnetV18alpha3 "github.com/CosmosContracts/juno/v21/app/upgrades/testnet/v18.0.0-alpha.3"
testnetV18alpha4 "github.com/CosmosContracts/juno/v21/app/upgrades/testnet/v18.0.0-alpha.4"
testnetV19alpha3 "github.com/CosmosContracts/juno/v21/app/upgrades/testnet/v19.0.0-alpha.3"
testnetV21alpha1 "github.com/CosmosContracts/juno/v21/app/upgrades/testnet/v21.0.0-alpha.1"
v10 "github.com/CosmosContracts/juno/v21/app/upgrades/v10"
v11 "github.com/CosmosContracts/juno/v21/app/upgrades/v11"
v12 "github.com/CosmosContracts/juno/v21/app/upgrades/v12"
Expand Down Expand Up @@ -109,7 +110,8 @@ var (
testnetV18alpha3.Upgrade,
testnetV18alpha4.Upgrade,
testnetV19alpha3.Upgrade,

testnetV21alpha1.Upgrade,

Check failure on line 114 in app/app.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s blank -s dot -s prefix(github.com/cometbft/cometbft) -s prefix(github.com/cosmos) -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmosContracts/juno) --custom-order (gci)
v10.Upgrade,
v11.Upgrade,
v12.Upgrade,
Expand Down
45 changes: 45 additions & 0 deletions app/upgrades/testnet/v21.0.0-alpha.1/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package v21

import (
"fmt"

store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/CosmosContracts/juno/v21/app/keepers"
"github.com/CosmosContracts/juno/v21/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name for the upgrade.
const UpgradeName = "v2100alpha1"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: v2100Alpha1UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{},
}

func v2100Alpha1UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
k *keepers.AppKeepers,

Check failure on line 27 in app/upgrades/testnet/v21.0.0-alpha.1/constants.go

View workflow job for this annotation

GitHub Actions / lint

unused-parameter: parameter 'k' seems to be unused, consider removing or renaming it as _ (revive)
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// Run migrations
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
if err != nil {
return nil, err
}
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))

return versionMap, err
}
}
40 changes: 40 additions & 0 deletions app/upgrades/testnet/v21.0.0-alpha.1/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package v21_test

import (
"testing"

"github.com/stretchr/testify/suite"

"github.com/CosmosContracts/juno/v21/app/apptesting"
v19alpha3 "github.com/CosmosContracts/juno/v21/app/upgrades/testnet/v19.0.0-alpha.3"
)

type UpgradeTestSuite struct {
apptesting.KeeperTestHelper
}

func (s *UpgradeTestSuite) SetupTest() {
s.Setup()
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

// Ensures the test does not error out.
func (s *UpgradeTestSuite) TestUpgrade() {
s.Setup()

preUpgradeChecks(s)

upgradeHeight := int64(5)
s.ConfirmUpgradeSucceeded(v19alpha3.UpgradeName, upgradeHeight)

postUpgradeChecks(s)
}

func preUpgradeChecks(_ *UpgradeTestSuite) {
}

func postUpgradeChecks(_ *UpgradeTestSuite) {
}

0 comments on commit 5e11005

Please sign in to comment.