From 1c71ba61876b229f40619efbfe0aa5994334ab59 Mon Sep 17 00:00:00 2001 From: Carlton N Hanna Date: Tue, 16 Apr 2024 15:25:58 -0600 Subject: [PATCH] add param tests --- x/msgfees/keeper/params_test.go | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 x/msgfees/keeper/params_test.go diff --git a/x/msgfees/keeper/params_test.go b/x/msgfees/keeper/params_test.go new file mode 100644 index 0000000000..8ee1bb3494 --- /dev/null +++ b/x/msgfees/keeper/params_test.go @@ -0,0 +1,53 @@ +package keeper_test + +import ( + "testing" + "time" + + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/app" + simapp "github.com/provenance-io/provenance/app" + "github.com/provenance-io/provenance/x/msgfees/types" + "github.com/stretchr/testify/suite" +) + +type MsgFeesParamTestSuite struct { + suite.Suite + + app *app.App + ctx sdk.Context +} + +func (s *MsgFeesParamTestSuite) SetupTest() { + s.app = simapp.Setup(s.T()) + s.ctx = s.app.BaseApp.NewContextLegacy(false, cmtproto.Header{Time: time.Now()}) +} + +func TestMsgFeesParamTestSuite(t *testing.T) { + suite.Run(t, new(MsgFeesParamTestSuite)) +} + +func (s *MsgFeesParamTestSuite) TestGetSetParams() { + defaultParams := s.app.MsgFeesKeeper.GetParams(s.ctx) + s.Require().Equal(types.DefaultFloorGasPrice(), defaultParams.FloorGasPrice, "Default FloorGasPrice should match") + s.Require().Equal(types.DefaultParams().NhashPerUsdMil, defaultParams.NhashPerUsdMil, "Default NhashPerUsdMil should match") + s.Require().Equal(types.DefaultParams().ConversionFeeDenom, defaultParams.ConversionFeeDenom, "Default ConversionFeeDenom should match") + + newFloorGasPrice := sdk.NewInt64Coin("nhash", 100) + newNhashPerUsdMil := uint64(25000000) + newConversionFeeDenom := "usd" + + newParams := types.Params{ + FloorGasPrice: newFloorGasPrice, + NhashPerUsdMil: newNhashPerUsdMil, + ConversionFeeDenom: newConversionFeeDenom, + } + + s.app.MsgFeesKeeper.SetParams(s.ctx, newParams) + + updatedParams := s.app.MsgFeesKeeper.GetParams(s.ctx) + s.Require().Equal(newFloorGasPrice, updatedParams.FloorGasPrice, "Updated FloorGasPrice should match") + s.Require().Equal(newNhashPerUsdMil, updatedParams.NhashPerUsdMil, "Updated NhashPerUsdMil should match") + s.Require().Equal(newConversionFeeDenom, updatedParams.ConversionFeeDenom, "Updated ConversionFeeDenom should match") +}