[ENG-540]: Process Proposal + Process Proposal Testing (#31)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user