[ENG-569]: PrepareProposal Testing (#29)
This commit is contained in:
+10
-4
@@ -48,7 +48,7 @@ func (ad AuctionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
|
||||
transactions[i] = decodedTx
|
||||
}
|
||||
|
||||
highestBid, err := ad.GetHighestAuctionBid(ctx)
|
||||
highestBid, err := ad.GetTopAuctionBid(ctx, tx)
|
||||
if err != nil {
|
||||
return ctx, errors.Wrap(err, "failed to get highest auction bid")
|
||||
}
|
||||
@@ -61,12 +61,18 @@ func (ad AuctionDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
|
||||
return next(ctx, tx, simulate)
|
||||
}
|
||||
|
||||
// GetHighestAuctionBid returns the highest auction bid if one exists.
|
||||
func (ad AuctionDecorator) GetHighestAuctionBid(ctx sdk.Context) (sdk.Coins, error) {
|
||||
// GetTopAuctionBid returns the highest auction bid if one exists. If the current transaction is the highest
|
||||
// bidding transaction, then an empty coin set is returned.
|
||||
func (ad AuctionDecorator) GetTopAuctionBid(ctx sdk.Context, currTx sdk.Tx) (sdk.Coins, error) {
|
||||
auctionTx := ad.mempool.GetTopAuctionTx(ctx)
|
||||
if auctionTx == nil {
|
||||
return sdk.NewCoins(), nil
|
||||
}
|
||||
|
||||
return auctionTx.(*mempool.WrappedBidTx).GetBid(), nil
|
||||
wrappedTx := auctionTx.(*mempool.WrappedBidTx)
|
||||
if wrappedTx.Tx == currTx {
|
||||
return sdk.NewCoins(), nil
|
||||
}
|
||||
|
||||
return wrappedTx.GetBid(), nil
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/skip-mev/pob/mempool"
|
||||
"github.com/skip-mev/pob/x/auction/ante"
|
||||
"github.com/skip-mev/pob/x/auction/keeper"
|
||||
"github.com/skip-mev/pob/x/auction/types"
|
||||
|
||||
@@ -24,7 +23,6 @@ type KeeperTestSuite struct {
|
||||
distrKeeper *MockDistributionKeeper
|
||||
stakingKeeper *MockStakingKeeper
|
||||
encCfg encodingConfig
|
||||
AuctionDecorator sdk.AnteDecorator
|
||||
ctx sdk.Context
|
||||
msgServer types.MsgServer
|
||||
key *storetypes.KVStoreKey
|
||||
@@ -66,6 +64,5 @@ func (suite *KeeperTestSuite) SetupTest() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
suite.mempool = mempool.NewAuctionMempool(suite.encCfg.TxConfig.TxDecoder(), 0)
|
||||
suite.AuctionDecorator = ante.NewAuctionDecorator(suite.auctionKeeper, suite.encCfg.TxConfig.TxDecoder(), suite.mempool)
|
||||
suite.msgServer = keeper.NewMsgServerImpl(suite.auctionKeeper)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user