Skip to content

Commit

Permalink
fix testing suite
Browse files Browse the repository at this point in the history
  • Loading branch information
aljo242 committed Aug 21, 2024
1 parent f05c309 commit 8f1b119
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
19 changes: 17 additions & 2 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ante

import (
"github.com/stretchr/testify/mock"
"testing"

"github.com/osmosis-labs/fee-abstraction/v8/x/feeabs/types"
Expand All @@ -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"
Expand Down Expand Up @@ -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,
},
{
Expand All @@ -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,
},
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions app/ante/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f1b119

Please sign in to comment.