From 0ce50fb340651b390497bc5b00616cbb28ef9d26 Mon Sep 17 00:00:00 2001 From: Aleksandr Pismenskiy Date: Mon, 19 Aug 2024 23:41:37 +0300 Subject: [PATCH] add TotalBurnedNeutronsAmount to genesis Init and Export methods in feeburner --- x/feeburner/genesis.go | 3 +++ x/feeburner/genesis_test.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/x/feeburner/genesis.go b/x/feeburner/genesis.go index 63291864d..205523f72 100644 --- a/x/feeburner/genesis.go +++ b/x/feeburner/genesis.go @@ -10,6 +10,8 @@ import ( // InitGenesis initializes the module's state from a provided genesis state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { // this line is used by starport scaffolding # genesis/module/init + k.RecordBurnedFees(ctx, genState.TotalBurnedNeutronsAmount.Coin) + err := k.SetParams(ctx, genState.Params) if err != nil { panic(err) @@ -20,6 +22,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + genesis.TotalBurnedNeutronsAmount = k.GetTotalBurnedNeutronsAmount(ctx) return genesis } diff --git a/x/feeburner/genesis_test.go b/x/feeburner/genesis_test.go index 6301c7b6d..39cac8755 100644 --- a/x/feeburner/genesis_test.go +++ b/x/feeburner/genesis_test.go @@ -3,8 +3,10 @@ package feeburner_test import ( "testing" + "cosmossdk.io/math" "github.com/neutron-org/neutron/v4/app/config" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/neutron-org/neutron/v4/testutil/common/nullify" @@ -16,14 +18,24 @@ import ( func TestGenesis(t *testing.T) { _ = config.GetDefaultConfig() + amount := math.NewInt(10) + genesisState := types.GenesisState{ Params: types.DefaultParams(), + TotalBurnedNeutronsAmount: types.TotalBurnedNeutronsAmount{ + Coin: sdk.NewCoin(types.DefaultNeutronDenom, amount), + }, } k, ctx := keeper.FeeburnerKeeper(t) feeburner.InitGenesis(ctx, *k, genesisState) + + burnedTokens := k.GetTotalBurnedNeutronsAmount(ctx) + require.Equal(t, amount, burnedTokens.Coin.Amount) + got := feeburner.ExportGenesis(ctx, *k) require.NotNil(t, got) + require.Equal(t, amount, got.TotalBurnedNeutronsAmount.Coin.Amount) nullify.Fill(&genesisState) nullify.Fill(got)