-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v4 upgrade #393
v4 upgrade #393
Changes from 6 commits
7c9a5bf
b52ac1a
917b9ec
a547c6a
77379a9
1d435b4
eca40f4
1d328c1
d676275
7790f15
5a6f5ff
1c62630
0bd774a
56b41e6
4b89d37
c0937f3
2b5b737
f0fd738
b3d18cf
d95face
9d5935c
cc899e1
1a5de7d
b0ddeb1
d9a2054
77ccbcc
5a990e1
1d2b8f3
a291585
4735226
76c5ebf
30cf02d
32b585d
6160c14
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,15 @@ package apptesting | |
|
||
import ( | ||
"strings" | ||
"time" | ||
|
||
abci "github.com/tendermint/tendermint/abci/types" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/baseapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types" | ||
transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" | ||
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" | ||
|
@@ -36,6 +39,7 @@ var ( | |
type AppTestHelper struct { | ||
suite.Suite | ||
|
||
Context sdk.Context | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rm |
||
App *app.StrideApp | ||
HostApp *simapp.SimApp | ||
|
||
|
@@ -57,6 +61,7 @@ func (s *AppTestHelper) Setup() { | |
GRPCQueryRouter: s.App.GRPCQueryRouter(), | ||
Ctx: s.Ctx(), | ||
} | ||
s.Context = s.App.BaseApp.NewContext(false, tmtypes.Header{Height: 1, ChainID: StrideChainID, Time: time.Now().UTC()}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rm |
||
s.TestAccs = CreateRandomAccounts(3) | ||
s.IbcEnabled = false | ||
s.IcaAddresses = make(map[string]string) | ||
|
@@ -311,3 +316,20 @@ func (s *AppTestHelper) ICS20PacketAcknowledgement() channeltypes.Acknowledgemen | |
ack := channeltypes.NewResultAcknowledgement(s.MarshalledICS20PacketData()) | ||
return ack | ||
} | ||
|
||
func (s *AppTestHelper) ConfirmUpgradeSucceededs(upgradeName string, upgradeHeight int64) { | ||
contextBeforeUpgrade := s.Ctx().WithBlockHeight(upgradeHeight - 1) | ||
contextAtUpgrade := s.Ctx().WithBlockHeight(upgradeHeight) | ||
|
||
plan := upgradetypes.Plan{Name: upgradeName, Height: upgradeHeight} | ||
err := s.App.UpgradeKeeper.ScheduleUpgrade(contextBeforeUpgrade, plan) | ||
s.Require().NoError(err) | ||
|
||
plan, exists := s.App.UpgradeKeeper.GetUpgradePlan(contextBeforeUpgrade) | ||
s.Require().True(exists) | ||
|
||
s.Require().NotPanics(func() { | ||
beginBlockRequest := abci.RequestBeginBlock{} | ||
s.App.BeginBlocker(contextAtUpgrade, beginBlockRequest) | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v3_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/Stride-Labs/stride/v3/app/apptesting" | ||
) | ||
var ( | ||
airdropIdentifiers = []string{"stride", "gaia", "osmosis", "juno", "stars"} | ||
) | ||
const dummyUpgradeHeight = 5 | ||
|
||
type UpgradeTestSuite struct { | ||
apptesting.AppTestHelper | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupTest() { | ||
s.Setup() | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestUpgrade() { | ||
testCases := []struct { | ||
msg string | ||
preUpdate func() | ||
update func() | ||
postUpdate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"Test that upgrade does not panic", | ||
func() { | ||
suite.Setup() | ||
}, | ||
func() { | ||
suite.ConfirmUpgradeSucceededs("v3", dummyUpgradeHeight) | ||
|
||
// make sure claim record was set | ||
afterCtx := suite.Ctx().WithBlockHeight(dummyUpgradeHeight) | ||
for _, identifier := range(airdropIdentifiers) { | ||
claimRecords := suite.App.ClaimKeeper.GetClaimRecords(afterCtx, identifier) | ||
suite.Require().NotEqual(0, len(claimRecords)) | ||
} | ||
}, | ||
func() { | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { | ||
tc.preUpdate() | ||
tc.update() | ||
tc.postUpdate() | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Upgrade v4 Changelog | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rm this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
1. Add authz storeKey to StoreLoader | ||
2. Add authz & claim modules to params subspaces | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v4 | ||
|
||
import ( | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
// Note: ensure these values are properly set before running upgrade | ||
var ( | ||
UpgradeName = "v4" | ||
) | ||
|
||
// CreateUpgradeHandler creates an SDK upgrade handler for v3 | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
newVm, err := mm.RunMigrations(ctx, configurator, vm) | ||
if err != nil { | ||
return newVm, err | ||
} | ||
return newVm, nil | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package v4_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
authz "github.com/cosmos/cosmos-sdk/x/authz" | ||
|
||
"github.com/Stride-Labs/stride/v3/app/apptesting" | ||
) | ||
|
||
const dummyUpgradeHeight = 5 | ||
|
||
type UpgradeTestSuite struct { | ||
apptesting.AppTestHelper | ||
} | ||
|
||
func (s *UpgradeTestSuite) SetupTest() { | ||
s.Setup() | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(UpgradeTestSuite)) | ||
} | ||
|
||
func (suite *UpgradeTestSuite) TestUpgrade() { | ||
testCases := []struct { | ||
msg string | ||
preUpdate func() | ||
update func() | ||
postUpdate func() | ||
expPass bool | ||
}{ | ||
{ | ||
"Test that upgrade does not panic", | ||
func() { | ||
suite.Setup() | ||
}, | ||
func() { | ||
suite.ConfirmUpgradeSucceededs("v4", dummyUpgradeHeight) | ||
|
||
// make sure authz module was init | ||
afterCtx := suite.Ctx().WithBlockHeight(dummyUpgradeHeight) | ||
actGenState := suite.App.AuthzKeeper.ExportGenesis(afterCtx) | ||
expGenState := authz.DefaultGenesisState() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
suite.Require().NotNil(actGenState) | ||
suite.Require().Equal(&expGenState, &actGenState) | ||
}, | ||
func() { | ||
}, | ||
true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { | ||
tc.preUpdate() | ||
tc.update() | ||
tc.postUpdate() | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this out of this upgrade