[ENG-540]: Process Proposal + Process Proposal Testing (#31)

This commit is contained in:
David Terpay
2023-03-22 14:06:15 -04:00
committed by GitHub
parent c8115a0d81
commit 717238ffd7
6 changed files with 411 additions and 22 deletions
+4
View File
@@ -54,6 +54,10 @@ func GetMsgAuctionBidFromTx(tx sdk.Tx) (*auctiontypes.MsgAuctionBid, error) {
// UnwrapBidTx attempts to unwrap a WrappedBidTx from an sdk.Tx if one exists.
func UnwrapBidTx(tx sdk.Tx) sdk.Tx {
if tx == nil {
return nil
}
wTx, ok := tx.(*WrappedBidTx)
if ok {
return wTx.Tx
+20
View File
@@ -3,6 +3,7 @@ package mempool_test
import (
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
pobcodec "github.com/skip-mev/pob/codec"
"github.com/skip-mev/pob/mempool"
@@ -46,3 +47,22 @@ func TestGetMsgAuctionBidFromTx_NoBid(t *testing.T) {
require.NoError(t, err)
require.Nil(t, msg)
}
func TestGetUnwrappedTx(t *testing.T) {
encCfg := pobcodec.CreateEncodingConfig()
txBuilder := encCfg.TxConfig.NewTxBuilder()
txBuilder.SetMsgs(&auctiontypes.MsgAuctionBid{})
tx := txBuilder.GetTx()
bid := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000000)))
wrappedTx := mempool.NewWrappedBidTx(tx, bid)
unWrappedTx := mempool.UnwrapBidTx(wrappedTx)
unwrappedBz, err := encCfg.TxConfig.TxEncoder()(unWrappedTx)
require.NoError(t, err)
txBz, err := encCfg.TxConfig.TxEncoder()(tx)
require.NoError(t, err)
require.Equal(t, txBz, unwrappedBz)
}