diff --git a/app/ante/ante_test.go b/app/ante/ante_test.go index b21efa9..9defdfc 100644 --- a/app/ante/ante_test.go +++ b/app/ante/ante_test.go @@ -1,6 +1,7 @@ package ante import ( + "github.com/stretchr/testify/mock" "testing" "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types" @@ -11,6 +12,7 @@ import ( "cosmossdk.io/errors" math "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -45,7 +47,10 @@ func TestMempoolDecorator(t *testing.T) { { "valid native fee, should pass", validFee, - func(suite *AnteTestSuite) {}, + func(suite *AnteTestSuite) { + suite.bankKeeper.On("SendCoinsFromAccountToModule", mock.Anything, mock.Anything, + feemarkettypes.FeeCollectorName, mock.Anything).Return(nil).Once() + }, nil, }, { @@ -56,6 +61,8 @@ func TestMempoolDecorator(t *testing.T) { require.NoError(t, err) suite.feeabsKeeper.SetTwapRate(suite.ctx, "ibcfee", math.LegacyNewDec(1)) suite.stakingKeeper.EXPECT().BondDenom(gomock.Any()).Return("ueve", nil).AnyTimes() + suite.bankKeeper.On("SendCoinsFromAccountToModule", mock.Anything, mock.Anything, + feemarkettypes.FeeCollectorName, mock.Anything).Return(nil).Once() }, nil, }, @@ -93,11 +100,19 @@ func TestMempoolDecorator(t *testing.T) { tc.malleate(suite) suite.txBuilder.SetGasLimit(gasLimit) suite.txBuilder.SetFeeAmount(tc.feeAmount) + accs := suite.CreateTestAccounts(1) + require.NoError(t, suite.txBuilder.SetMsgs([]sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}...)) + suite.ctx = suite.ctx.WithMinGasPrices(minGasPrice) // Construct tx and run through mempool decorator tx := suite.txBuilder.GetTx() - feemarketDecorator := feemarketante.NewFeeMarketCheckDecorator(suite.feemarketKeeper, nil) + feemarketDecorator := feemarketante.NewFeeMarketCheckDecorator( + suite.accountKeeper, + suite.bankKeeper, + suite.feeGrantKeeper, + suite.feemarketKeeper, + nil) antehandler := sdk.ChainAnteDecorators(feemarketDecorator) // Run the ante handler diff --git a/app/ante/suite.go b/app/ante/suite.go index 90faa78..1413c21 100644 --- a/app/ante/suite.go +++ b/app/ante/suite.go @@ -11,6 +11,7 @@ import ( feeabstestutil "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/testutil" feeabstypes "github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types" feemarketante "github.com/skip-mev/feemarket/x/feemarket/ante" + feemarketmocks "github.com/skip-mev/feemarket/x/feemarket/ante/mocks" feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper" feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types" "github.com/stretchr/testify/require" @@ -45,7 +46,7 @@ type AnteTestSuite struct { clientCtx client.Context txBuilder client.TxBuilder accountKeeper authkeeper.AccountKeeper - bankKeeper *feeabstestutil.MockBankKeeper + bankKeeper *feemarketmocks.BankKeeper feeGrantKeeper *feeabstestutil.MockFeegrantKeeper stakingKeeper *feeabstestutil.MockStakingKeeper feeabsKeeper feeabskeeper.Keeper @@ -65,7 +66,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { govAuthority := authtypes.NewModuleAddress("gov").String() // Setup mock keepers - suite.bankKeeper = feeabstestutil.NewMockBankKeeper(ctrl) + suite.bankKeeper = feemarketmocks.NewBankKeeper(t) suite.stakingKeeper = feeabstestutil.NewMockStakingKeeper(ctrl) suite.feeGrantKeeper = feeabstestutil.NewMockFeegrantKeeper(ctrl) suite.channelKeeper = feeabstestutil.NewMockChannelKeeper(ctrl) @@ -99,7 +100,8 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) testdata.RegisterInterfaces(suite.encCfg.InterfaceRegistry) suite.accountKeeper = authkeeper.NewAccountKeeper( - suite.encCfg.Codec, runtime.NewKVStoreService(key), authtypes.ProtoBaseAccount, maccPerms, authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.Bech32MainPrefix, govAuthority, + suite.encCfg.Codec, runtime.NewKVStoreService(authKey), authtypes.ProtoBaseAccount, maccPerms, + authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.Bech32MainPrefix, govAuthority, ) suite.accountKeeper.SetModuleAccount(suite.ctx, authtypes.NewEmptyModuleAccount(feeabstypes.ModuleName)) // Setup feeabs keeper diff --git a/go.mod b/go.mod index ba25f06..1b5de49 100644 --- a/go.mod +++ b/go.mod @@ -185,6 +185,7 @@ require ( github.com/shamaton/msgpack/v2 v2.2.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tidwall/btree v1.7.0 // indirect