Skip to content

Commit

Permalink
test: add test upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 committed Jan 10, 2024
1 parent 3e2c28d commit a5ed8f4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/upgrades/v4_1_0/constants.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v3
package v4

// UpgradeName defines the on-chain upgrade name for the Migaloo v3.0.2 upgrade.
// this upgrade includes the fix for pfm
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v4_1_0/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v3
package v4

import (
"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -14,7 +14,7 @@ import (
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
)

// small security fix, can be a no-op, running mm.RunMigarions just to be sure
// CreateUpgradeHandler small security fix, can be a no-op, running mm.RunMigarions just to be sure
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand Down
45 changes: 45 additions & 0 deletions app/upgrades/v4_1_0/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package v4_test

import (
abci "github.com/cometbft/cometbft/abci/types"
"testing"

apptesting "github.com/White-Whale-Defi-Platform/migaloo-chain/v3/app"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/stretchr/testify/suite"
)

const (
v4UpgradeHeight = int64(10)
)

type UpgradeTestSuite struct {
apptesting.KeeperTestHelper
}

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

func (suite *UpgradeTestSuite) TestUpgrade() {
suite.Setup(suite.T(), apptesting.SimAppChainID)
dummyUpgrade(suite)
feeBurnParam := suite.App.FeeBurnKeeper.GetParams(suite.Ctx)
suite.Require().Equal("0", feeBurnParam.GetTxFeeBurnPercent())
}

func dummyUpgrade(s *UpgradeTestSuite) {
s.Ctx = s.Ctx.WithBlockHeight(v4UpgradeHeight - 1)
plan := upgradetypes.Plan{Name: "v4.1.0", Height: v4UpgradeHeight}
err := s.App.UpgradeKeeper.ScheduleUpgrade(s.Ctx, plan)
s.Require().NoError(err)
_, exists := s.App.UpgradeKeeper.GetUpgradePlan(s.Ctx)
s.Require().True(exists)

s.Ctx = s.Ctx.WithBlockHeight(v4UpgradeHeight)

s.Require().NotPanics(func() {
beginBlockRequest := abci.RequestBeginBlock{}
s.App.BeginBlocker(s.Ctx, beginBlockRequest)
})
}

0 comments on commit a5ed8f4

Please sign in to comment.