Skip to content

Commit

Permalink
v5.0.4 upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Dec 17, 2024
1 parent d29c0b2 commit 981f77c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2"
v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4"
dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types"

"github.com/skip-mev/feemarket/x/feemarket"
Expand Down Expand Up @@ -230,6 +231,7 @@ var (
Upgrades = []upgrades.Upgrade{
v500.Upgrade,
v502.Upgrade,
v504.Upgrade,
}

// DefaultNodeHome default home directories for the application daemon
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v5.0.4/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v504

import (
storetypes "cosmossdk.io/store/types"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.4"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{},
}
35 changes: 35 additions & 0 deletions app/upgrades/v5.0.4/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package v504

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/neutron-org/neutron/v5/app/upgrades"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
_ *upgrades.UpgradeKeepers,
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")

vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
}
37 changes: 37 additions & 0 deletions app/upgrades/v5.0.4/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package v504_test

import (
"testing"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"

v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4"
"github.com/neutron-org/neutron/v5/testutil"
)

type UpgradeTestSuite struct {
testutil.IBCConnectionTestSuite
}

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

func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestOracleUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext().WithChainID("neutron-1")
t := suite.T()

upgrade := upgradetypes.Plan{
Name: v504.UpgradeName,
Info: "some text here",
Height: 100,
}
require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade))
}

0 comments on commit 981f77c

Please sign in to comment.