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 authored and pr0n00gler committed Aug 21, 2024
1 parent a67fd9e commit 1575c17
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 @@ -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)
Expand All @@ -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
}
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 1575c17

Please sign in to comment.