From f63e6d88dd7cbd65dc0002d05475ace3deca2c6c Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 28 Dec 2023 20:38:19 +0900 Subject: [PATCH] use sdk.DefaultBondDenom for testing --- x/opchild/ante/fee_test.go | 34 ++++++++++++++--------------- x/opchild/keeper/common_test.go | 4 +--- x/opchild/keeper/msg_server_test.go | 6 ++--- x/ophost/keeper/common_test.go | 4 +--- x/ophost/keeper/msg_server_test.go | 6 ++--- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/x/opchild/ante/fee_test.go b/x/opchild/ante/fee_test.go index 74190ae9..e03a395b 100644 --- a/x/opchild/ante/fee_test.go +++ b/x/opchild/ante/fee_test.go @@ -11,8 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" ) -var baseDenom = sdk.DefaultBondDenom - type TestAnteKeeper struct { minGasPrices sdk.DecCoins } @@ -27,7 +25,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // set price 0.5 base == 1 quote fc := ante.NewMempoolFeeChecker(TestAnteKeeper{ - minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyZeroDec())), + minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyZeroDec())), }) // keys and addresses @@ -36,7 +34,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // msg and signatures // gas price 0.0005 msg := testdata.NewTestMsg(addr1) - feeAmount := sdk.NewCoins(sdk.NewCoin(baseDenom, math.NewInt(100))) + feeAmount := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) gasLimit := uint64(200_000) suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) @@ -48,7 +46,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.Require().NoError(err) // Set high gas price so standard test fee fails - basePrice := sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000))) + basePrice := sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000))) highGasPrice := []sdk.DecCoin{basePrice} suite.ctx = suite.ctx.WithMinGasPrices(highGasPrice) @@ -70,7 +68,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { suite.ctx = suite.ctx.WithIsCheckTx(true) // gas price = 0.0005 - basePrice = sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDecWithPrec(5, 4)) + basePrice = sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDecWithPrec(5, 4)) lowGasPrice := []sdk.DecCoin{basePrice} suite.ctx = suite.ctx.WithMinGasPrices(lowGasPrice) @@ -79,7 +77,7 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { // set high base_min_gas_price to test should be failed fc = ante.NewMempoolFeeChecker(TestAnteKeeper{ - minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000)))), + minGasPrices: sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(200).Quo(math.LegacyNewDec(100000)))), }) suite.txBuilder.SetFeeAmount(feeAmount) @@ -88,33 +86,33 @@ func (suite *AnteTestSuite) TestEnsureMempoolFees() { } func (suite *AnteTestSuite) TestCombinedMinGasPrices() { - minGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100))) - configMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100))) + minGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100))) + configMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100))) combined := ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(100))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(100))) - configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(150))) + configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(150))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(150))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(150))) - minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(200))) + minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(200))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 1) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(200))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(200))) - configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test", math.LegacyNewDec(100))) + configMinGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test", math.LegacyNewDec(100))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 2) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(200))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(200))) suite.Require().True(combined.AmountOf("test").Equal(math.LegacyNewDec(100))) - minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test2", math.LegacyNewDec(300))) + minGasPrices = sdk.NewDecCoins(sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, math.LegacyNewDec(100)), sdk.NewDecCoinFromDec("test2", math.LegacyNewDec(300))) combined = ante.CombinedMinGasPrices(minGasPrices, configMinGasPrices) suite.Require().Len(combined, 3) - suite.Require().True(combined.AmountOf(baseDenom).Equal(math.LegacyNewDec(100))) + suite.Require().True(combined.AmountOf(sdk.DefaultBondDenom).Equal(math.LegacyNewDec(100))) suite.Require().True(combined.AmountOf("test").Equal(math.LegacyNewDec(100))) suite.Require().True(combined.AmountOf("test2").Equal(math.LegacyNewDec(300))) } diff --git a/x/opchild/keeper/common_test.go b/x/opchild/keeper/common_test.go index 83a69847..aedf2e50 100644 --- a/x/opchild/keeper/common_test.go +++ b/x/opchild/keeper/common_test.go @@ -47,8 +47,6 @@ import ( opchildtypes "github.com/initia-labs/OPinit/x/opchild/types" ) -const baseDenom = "umin" - var ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, @@ -145,7 +143,7 @@ func MakeEncodingConfig(_ testing.TB) EncodingConfig { } func initialTotalSupply() sdk.Coins { - faucetBalance := sdk.NewCoins(sdk.NewCoin(baseDenom, initiaSupply)) + faucetBalance := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initiaSupply)) for _, testDenom := range testDenoms { faucetBalance = faucetBalance.Add(sdk.NewCoin(testDenom, initiaSupply)) } diff --git a/x/opchild/keeper/msg_server_test.go b/x/opchild/keeper/msg_server_test.go index 5d3b75cf..f597a8c0 100644 --- a/x/opchild/keeper/msg_server_test.go +++ b/x/opchild/keeper/msg_server_test.go @@ -185,10 +185,10 @@ func Test_MsgServer_SpendFeePool(t *testing.T) { ms := keeper.NewMsgServerImpl(input.OPChildKeeper) // fund fee pool - collectedFees := sdk.NewCoins(sdk.NewCoin(baseDenom, math.NewInt(100))) + collectedFees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100))) input.Faucet.Fund(ctx, authtypes.NewModuleAddress(authtypes.FeeCollectorName), collectedFees...) - beforeAmount := input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).Amount + beforeAmount := input.BankKeeper.GetBalance(ctx, addrs[1], sdk.DefaultBondDenom).Amount msg := types.NewMsgSpendFeePool( authtypes.NewModuleAddress(types.ModuleName), @@ -198,7 +198,7 @@ func Test_MsgServer_SpendFeePool(t *testing.T) { _, err := ms.SpendFeePool(ctx, msg) require.NoError(t, err) - afterAmount := input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).Amount + afterAmount := input.BankKeeper.GetBalance(ctx, addrs[1], sdk.DefaultBondDenom).Amount require.Equal(t, beforeAmount.Add(math.NewInt(100)), afterAmount) } diff --git a/x/ophost/keeper/common_test.go b/x/ophost/keeper/common_test.go index 8ec9143e..b011c6b6 100644 --- a/x/ophost/keeper/common_test.go +++ b/x/ophost/keeper/common_test.go @@ -48,8 +48,6 @@ import ( ophosttypes "github.com/initia-labs/OPinit/x/ophost/types" ) -const baseDenom = "umin" - var ModuleBasics = module.NewBasicManager( auth.AppModuleBasic{}, bank.AppModuleBasic{}, @@ -130,7 +128,7 @@ func MakeEncodingConfig(_ testing.TB) EncodingConfig { } func initialTotalSupply() sdk.Coins { - faucetBalance := sdk.NewCoins(sdk.NewCoin(baseDenom, initiaSupply)) + faucetBalance := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initiaSupply)) for _, testDenom := range testDenoms { faucetBalance = faucetBalance.Add(sdk.NewCoin(testDenom, initiaSupply)) } diff --git a/x/ophost/keeper/msg_server_test.go b/x/ophost/keeper/msg_server_test.go index 7c0d6477..d2a1b85b 100644 --- a/x/ophost/keeper/msg_server_test.go +++ b/x/ophost/keeper/msg_server_test.go @@ -133,15 +133,15 @@ func Test_InitiateTokenDeposit(t *testing.T) { require.NoError(t, err) require.Equal(t, uint64(1), createRes.BridgeId) - amount := sdk.NewCoin(baseDenom, math.NewInt(100)) + amount := sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(100)) input.Faucet.Fund(ctx, addrs[1], amount) _, err = ms.InitiateTokenDeposit( ctx, types.NewMsgInitiateTokenDeposit(addrsStr[1], 1, addrsStr[2], amount, []byte("messages")), ) require.NoError(t, err) - require.True(t, input.BankKeeper.GetBalance(ctx, addrs[1], baseDenom).IsZero()) - require.Equal(t, amount, input.BankKeeper.GetBalance(ctx, types.BridgeAddress(1), baseDenom)) + require.True(t, input.BankKeeper.GetBalance(ctx, addrs[1], sdk.DefaultBondDenom).IsZero()) + require.Equal(t, amount, input.BankKeeper.GetBalance(ctx, types.BridgeAddress(1), sdk.DefaultBondDenom)) } func Test_FinalizeTokenWithdrawal(t *testing.T) {