Skip to content

Commit

Permalink
add TotalBurnedNeutronsAmount to genesis Init and Export methods in f…
Browse files Browse the repository at this point in the history
…eeburner
  • Loading branch information
joldie777 committed Aug 19, 2024
1 parent 95d8653 commit 16a0c40
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions x/feeburner/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)
if err != nil {
panic(err)
}

k.RecordBurnedFees(ctx, genState.TotalBurnedNeutronsAmount.Coin)
}

// ExportGenesis returns the module's exported genesis
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
}
12 changes: 12 additions & 0 deletions x/feeburner/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down

0 comments on commit 16a0c40

Please sign in to comment.