Skip to content

Commit

Permalink
WIP: add tests for mint BeginBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
gsk967 committed Jul 17, 2023
1 parent 59f23d2 commit d3d27fe
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions x/mint/module/abci_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package mint_test

import (
"fmt"
"testing"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
mintmodule "github.com/umee-network/umee/v5/x/mint/module"
"gotest.tools/v3/assert"

umeeapp "github.com/umee-network/umee/v5/app"
)

func TestBeginBlock(t *testing.T) {
app := umeeapp.Setup(t)
ctx := app.NewContext(false, tmproto.Header{
ChainID: fmt.Sprintf("test-chain-%s", tmrand.Str(4)),
})

// sdk context should start with current time to make sure to update the inflation min and max rate
ctx = ctx.WithBlockTime(time.Now())

oldMintParams := app.MintKeeper.GetParams(ctx)
uk := app.UGovKeeperB.Keeper(&ctx)
mintmodule.BeginBlock(ctx, uk, app.MintKeeper)

// inflation min and max rate should change by reduce rate
newMintParams := app.MintKeeper.GetParams(ctx)
liquidationParams := uk.LiquidationParams()
assert.DeepEqual(t,
oldMintParams.InflationMax.Mul(sdk.OneDec().Sub(liquidationParams.InflationReductionRate)),
newMintParams.InflationMax,
)
assert.DeepEqual(t,
oldMintParams.InflationMin.Mul(sdk.OneDec().Sub(liquidationParams.InflationReductionRate)),
newMintParams.InflationMin,
)
}

0 comments on commit d3d27fe

Please sign in to comment.