From d3d27fedd614040d5c3449da126d00df26d782b3 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Mon, 17 Jul 2023 20:05:04 +0530 Subject: [PATCH] WIP: add tests for mint BeginBlock --- x/mint/module/abci_test.go | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 x/mint/module/abci_test.go diff --git a/x/mint/module/abci_test.go b/x/mint/module/abci_test.go new file mode 100644 index 0000000000..c480f3ec6e --- /dev/null +++ b/x/mint/module/abci_test.go @@ -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, + ) +}