Add x/incentive module migrations (#1224)

This commit is contained in:
Levi Schoen 2022-04-22 16:30:09 -07:00 committed by GitHub
parent 6ad85f09b7
commit c5de1302f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 2 deletions

View File

@ -17,6 +17,7 @@ import (
v016auction "github.com/kava-labs/kava/x/auction/legacy/v0_16"
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"
)
func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
@ -74,4 +75,12 @@ func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
appState[auctiontypes.ModuleName] = encodedState
}
// x/incentive
if appState[incentivetypes.ModuleName] != nil {
var incentiveState incentivetypes.GenesisState
codec.MustUnmarshalJSON(appState[incentivetypes.ModuleName], &incentiveState)
appState[incentivetypes.ModuleName] = codec.MustMarshalJSON(&incentiveState)
}
}

View File

@ -20,6 +20,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"
)
func TestMigrateGenesisDoc(t *testing.T) {
@ -59,7 +60,7 @@ func TestMigrateEvm(t *testing.T) {
})
}
func TestMigrateXAuction(t *testing.T) {
func TestMigrateAuction(t *testing.T) {
appMap, ctx := migrateToV17AndGetAppMap(t)
var genstate auctiontypes.GenesisState
err := ctx.Codec.UnmarshalJSON(appMap[auctiontypes.ModuleName], &genstate)
@ -101,6 +102,17 @@ func TestMigrateBridge(t *testing.T) {
})
}
func TestMigrateIncentive(t *testing.T) {
appMap, ctx := migrateToV17AndGetAppMap(t)
var genstate incentivetypes.GenesisState
err := ctx.Codec.UnmarshalJSON(appMap[incentivetypes.ModuleName], &genstate)
assert.NoError(t, err)
assert.Len(t, genstate.SavingsClaims, 0)
assert.Len(t, genstate.SavingsRewardState.AccumulationTimes, 0)
assert.Len(t, genstate.SavingsRewardState.MultiRewardIndexes, 0)
assert.Len(t, genstate.Params.SavingsRewardPeriods, 0)
}
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

@ -1745,7 +1745,8 @@
]
}
],
"claim_end": "2025-01-01T00:00:00Z"
"claim_end": "2025-01-01T00:00:00Z",
"savings_reward_periods": []
},
"usdx_reward_state": {
"accumulation_times": [
@ -1947,6 +1948,11 @@
]
}
],
"savings_claims": [],
"savings_reward_state": {
"accumulation_times": [],
"multi_reward_indexes": []
},
"swap_claims": [
{
"base_claim": {