diff --git a/app/upgrades/v6/upgrades.go b/app/upgrades/v6/upgrades.go index 406051cd..2853b5c1 100644 --- a/app/upgrades/v6/upgrades.go +++ b/app/upgrades/v6/upgrades.go @@ -2,12 +2,8 @@ package v6 import ( "context" - "maps" - "slices" - "strings" upgradetypes "cosmossdk.io/x/upgrade/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/milkyway-labs/milkyway/v6/app/keepers" @@ -25,33 +21,6 @@ func CreateUpgradeHandler( return nil, err } - // Unwrap the context - sdkCtx := sdk.UnwrapSDKContext(ctx) - - // Remove all the markets except from the TIA/USD market - markets, err := keepers.MarketMapKeeper.GetAllMarkets(sdkCtx) - if err != nil { - return nil, err - } - - for _, ticker := range slices.Sorted(maps.Keys(markets)) { - market := markets[ticker] - - if strings.Contains(ticker, "TIA") { - continue - } - - err = keepers.MarketMapKeeper.DeleteMarket(sdkCtx, ticker) - if err != nil { - return nil, err - } - - err = keepers.OracleKeeper.RemoveCurrencyPair(sdkCtx, market.Ticker.CurrencyPair) - if err != nil { - return nil, err - } - } - keepers.AccountKeeper.GetModuleAccount(ctx, liquidvestingtypes.ModuleName) return vm, nil diff --git a/app/upgrades/v6/upgrades_test.go b/app/upgrades/v6/upgrades_test.go deleted file mode 100644 index 2644aeb8..00000000 --- a/app/upgrades/v6/upgrades_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package v6_test - -import ( - "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/header" - "cosmossdk.io/x/upgrade" - upgradetypes "cosmossdk.io/x/upgrade/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/stretchr/testify/suite" - - milkywayapp "github.com/milkyway-labs/milkyway/v6/app" - "github.com/milkyway-labs/milkyway/v6/app/helpers" - v6 "github.com/milkyway-labs/milkyway/v6/app/upgrades/v6" - liquidvestingtypes "github.com/milkyway-labs/milkyway/v6/x/liquidvesting/types" -) - -//func TestUpgradeTestSuite(t *testing.T) { -// suite.Run(t, new(UpgradeTestSuite)) -//} - -type UpgradeTestSuite struct { - suite.Suite - - App *milkywayapp.MilkyWayApp - Ctx sdk.Context - UpgradeModule appmodule.HasPreBlocker -} - -func (suite *UpgradeTestSuite) SetupTest() { - suite.App = helpers.Setup(suite.T()) - suite.Ctx = suite.App.NewUncachedContext(true, tmproto.Header{}) - suite.Ctx = suite.Ctx.WithHeaderInfo(header.Info{Height: 1}) - suite.UpgradeModule = upgrade.NewAppModule(suite.App.UpgradeKeeper, suite.App.AccountKeeper.AddressCodec()) -} - -func (suite *UpgradeTestSuite) TestUpgradeV6() { - // Make sure the markets are set - markets, err := suite.App.MarketMapKeeper.GetAllMarkets(suite.Ctx) - suite.Require().NoError(err) - suite.Require().Len(markets, 63) - - // Make sure the currency pairs are set - currencyPairs := suite.App.OracleKeeper.GetAllCurrencyPairs(suite.Ctx) - suite.Require().Len(currencyPairs, 63) - - // Perform the upgrade - suite.performUpgrade() - - // Make sure only the TIA/USD market is left - markets, err = suite.App.MarketMapKeeper.GetAllMarkets(suite.Ctx) - suite.Require().NoError(err) - suite.Require().Len(markets, 1) - suite.Require().Equal("TIA/USD", markets["TIA/USD"].Ticker.String()) - - // Make sure the only currency pair left is TIA/USD - currencyPairs = suite.App.OracleKeeper.GetAllCurrencyPairs(suite.Ctx) - suite.Require().Len(currencyPairs, 1) - suite.Require().Equal("TIA/USD", currencyPairs[0].String()) - - acc := suite.App.AccountKeeper.GetAccount(suite.Ctx, authtypes.NewModuleAddress(liquidvestingtypes.ModuleName)) - _, ok := acc.(sdk.ModuleAccountI) - suite.Require().True(ok) -} - -func (suite *UpgradeTestSuite) performUpgrade() { - upgradeHeight := suite.Ctx.HeaderInfo().Height + 1 - - // Schedule the upgrade - err := suite.App.UpgradeKeeper.ScheduleUpgrade(suite.Ctx, upgradetypes.Plan{Name: v6.UpgradeName, Height: upgradeHeight}) - suite.Require().NoError(err) - - // Make sure the upgrade plan is set - _, err = suite.App.UpgradeKeeper.GetUpgradePlan(suite.Ctx) - suite.Require().NoError(err) - - // Fast-forward to the upgrade height - suite.Ctx = suite.Ctx.WithHeaderInfo(header.Info{Height: upgradeHeight}) - - // Run PreBlocker to trigger the upgrade - _, err = suite.UpgradeModule.PreBlock(suite.Ctx) - suite.Require().NoError(err) -}