[ENG-569]: PrepareProposal Testing (#29)

This commit is contained in:
David Terpay
2023-03-21 10:07:14 -04:00
committed by GitHub
parent 9e350bc7f7
commit c8115a0d81
7 changed files with 841 additions and 31 deletions
+10 -4
View File
@@ -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
}
-3
View File
@@ -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)
}