mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 03:37:28 +00:00 
			
		
		
		
	x/savings migration (#1226)
This commit is contained in:
		
							parent
							
								
									35da890db0
								
							
						
					
					
						commit
						39d6176080
					
				@ -18,6 +18,7 @@ import (
 | 
				
			|||||||
	v017auction "github.com/kava-labs/kava/x/auction/legacy/v0_17"
 | 
						v017auction "github.com/kava-labs/kava/x/auction/legacy/v0_17"
 | 
				
			||||||
	auctiontypes "github.com/kava-labs/kava/x/auction/types"
 | 
						auctiontypes "github.com/kava-labs/kava/x/auction/types"
 | 
				
			||||||
	incentivetypes "github.com/kava-labs/kava/x/incentive/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) {
 | 
					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)
 | 
							appState[incentivetypes.ModuleName] = codec.MustMarshalJSON(&incentiveState)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// x/savings
 | 
				
			||||||
 | 
						savingsState := savingstypes.DefaultGenesisState()
 | 
				
			||||||
 | 
						appState[savingstypes.ModuleName] = codec.MustMarshalJSON(&savingsState)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -21,6 +21,7 @@ import (
 | 
				
			|||||||
	auctiontypes "github.com/kava-labs/kava/x/auction/types"
 | 
						auctiontypes "github.com/kava-labs/kava/x/auction/types"
 | 
				
			||||||
	evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
 | 
						evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
 | 
				
			||||||
	incentivetypes "github.com/kava-labs/kava/x/incentive/types"
 | 
						incentivetypes "github.com/kava-labs/kava/x/incentive/types"
 | 
				
			||||||
 | 
						savingstypes "github.com/kava-labs/kava/x/savings/types"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestMigrateGenesisDoc(t *testing.T) {
 | 
					func TestMigrateGenesisDoc(t *testing.T) {
 | 
				
			||||||
@ -113,6 +114,17 @@ func TestMigrateIncentive(t *testing.T) {
 | 
				
			|||||||
	assert.Len(t, genstate.Params.SavingsRewardPeriods, 0)
 | 
						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) {
 | 
					func migrateToV17AndGetAppMap(t *testing.T) (genutiltypes.AppMap, client.Context) {
 | 
				
			||||||
	genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v16.json"))
 | 
						genDoc, err := tmtypes.GenesisDocFromFile(filepath.Join("testdata", "genesis-v16.json"))
 | 
				
			||||||
	assert.NoError(t, err)
 | 
						assert.NoError(t, err)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								migrate/v0_17/testdata/genesis-v17.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								migrate/v0_17/testdata/genesis-v17.json
									
									
									
									
										vendored
									
									
								
							@ -2239,6 +2239,12 @@
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
    "authz": {
 | 
					    "authz": {
 | 
				
			||||||
      "authorization": []
 | 
					      "authorization": []
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    "savings": {
 | 
				
			||||||
 | 
					      "deposits": [],
 | 
				
			||||||
 | 
					      "params": {
 | 
				
			||||||
 | 
					        "supported_denoms": []
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user