-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from crescent-network/mm-order
refactor!: modify mm order
- Loading branch information
Showing
57 changed files
with
7,720 additions
and
45,025 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package v5 | ||
|
||
import ( | ||
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" | ||
) | ||
|
||
const UpgradeName = "v5" | ||
|
||
func UpgradeHandler( | ||
mm *module.Manager, configurator module.Configurator) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} | ||
|
||
var StoreUpgrades = store.StoreUpgrades{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package v5_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
"github.com/stretchr/testify/suite" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
|
||
chain "github.com/crescent-network/crescent/v4/app" | ||
v5 "github.com/crescent-network/crescent/v4/app/upgrades/mainnet/v5" | ||
"github.com/crescent-network/crescent/v4/cmd/crescentd/cmd" | ||
utils "github.com/crescent-network/crescent/v4/types" | ||
liquiditytypes "github.com/crescent-network/crescent/v4/x/liquidity/types" | ||
) | ||
|
||
type UpgradeTestSuite struct { | ||
suite.Suite | ||
ctx sdk.Context | ||
app *chain.App | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupTest() { | ||
cmd.GetConfig() | ||
s.app = chain.Setup(false) | ||
s.ctx = s.app.BaseApp.NewContext(false, tmproto.Header{ | ||
Height: 1, | ||
Time: utils.ParseTime("2023-03-01T00:00:00Z"), | ||
}) | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
const testUpgradeHeight = 10 | ||
|
||
func (s *UpgradeTestSuite) TestUpgradeV5() { | ||
testCases := []struct { | ||
title string | ||
before func() | ||
after func() | ||
expPass bool | ||
}{ | ||
{ | ||
"v5 upgrade liquidity", | ||
func() {}, | ||
func() { | ||
liquidityParams := s.app.LiquidityKeeper.GetParams(s.ctx) | ||
s.Require().EqualValues( | ||
liquidityParams.MaxNumMarketMakingOrdersPerPair, liquiditytypes.DefaultMaxNumMarketMakingOrdersPerPair) | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
s.Run(tc.title, func() { | ||
s.SetupTest() | ||
|
||
tc.before() | ||
|
||
s.ctx = s.ctx.WithBlockHeight(testUpgradeHeight - 1) | ||
plan := upgradetypes.Plan{Name: v5.UpgradeName, Height: testUpgradeHeight} | ||
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(testUpgradeHeight) | ||
s.Require().NotPanics(func() { | ||
s.app.BeginBlocker(s.ctx, abci.RequestBeginBlock{}) | ||
}) | ||
|
||
tc.after() | ||
}) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.