x/savings migration (#1226)

This commit is contained in:
Draco Li 2022-04-25 15:48:59 -04:00 committed by GitHub
parent 35da890db0
commit 39d6176080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import (
v017auction "github.com/kava-labs/kava/x/auction/legacy/v0_17"
auctiontypes "github.com/kava-labs/kava/x/auction/types"
incentivetypes "github.com/kava-labs/kava/x/incentive/types"
savingstypes "github.com/kava-labs/kava/x/savings/types"
)
func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
@ -83,4 +84,8 @@ func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
appState[incentivetypes.ModuleName] = codec.MustMarshalJSON(&incentiveState)
}
// x/savings
savingsState := savingstypes.DefaultGenesisState()
appState[savingstypes.ModuleName] = codec.MustMarshalJSON(&savingsState)
}

View File

@ -21,6 +21,7 @@ import (
auctiontypes "github.com/kava-labs/kava/x/auction/types"
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
incentivetypes "github.com/kava-labs/kava/x/incentive/types"
savingstypes "github.com/kava-labs/kava/x/savings/types"
)
func TestMigrateGenesisDoc(t *testing.T) {
@ -113,6 +114,17 @@ func TestMigrateIncentive(t *testing.T) {
assert.Len(t, genstate.Params.SavingsRewardPeriods, 0)
}
func TestMigrateSavings(t *testing.T) {
appMap, ctx := migrateToV17AndGetAppMap(t)
var genstate savingstypes.GenesisState
err := ctx.Codec.UnmarshalJSON(appMap[savingstypes.ModuleName], &genstate)
assert.NoError(t, err)
assert.Len(t, genstate.Deposits, 0)
assert.Equal(t, genstate.Params, savingstypes.Params{
SupportedDenoms: []string{},
})
}
func migrateToV17AndGetAppMap(t *testing.T) (genutiltypes.AppMap, client.Context) {
genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v16.json"))
assert.NoError(t, err)

View File

@ -2239,6 +2239,12 @@
},
"authz": {
"authorization": []
},
"savings": {
"deposits": [],
"params": {
"supported_denoms": []
}
}
}
}