mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
Add x/incentive module migrations (#1224)
This commit is contained in:
parent
6ad85f09b7
commit
c5de1302f6
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
8
migrate/v0_17/testdata/genesis-v17.json
vendored
8
migrate/v0_17/testdata/genesis-v17.json
vendored
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user