|
|
|
@@ -12,6 +12,10 @@ import (
|
|
|
|
|
"github.com/strangelove-ventures/interchaintest/v7/ibc"
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
"github.com/stretchr/testify/suite"
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
|
|
|
|
rpctypes "github.com/cometbft/cometbft/rpc/core/types"
|
|
|
|
|
"bytes"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
@@ -31,6 +35,12 @@ type IntegrationTestSuite struct {
|
|
|
|
|
user1, user2, user3 ibc.Wallet
|
|
|
|
|
// denom
|
|
|
|
|
denom string
|
|
|
|
|
|
|
|
|
|
// overrides for key-ring configuration of the broadcaster
|
|
|
|
|
broadcasterOverrides *KeyringOverride
|
|
|
|
|
|
|
|
|
|
// broadcaster is the RPC interface to the ITS network
|
|
|
|
|
bc *cosmos.Broadcaster
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewIntegrationTestSuiteFromSpec(spec *interchaintest.ChainSpec) *IntegrationTestSuite {
|
|
|
|
@@ -50,6 +60,13 @@ func (s *IntegrationTestSuite) WithDenom(denom string) *IntegrationTestSuite {
|
|
|
|
|
return s
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *IntegrationTestSuite) WithKeyringOptions(cdc codec.Codec, opts keyring.Option) {
|
|
|
|
|
s.broadcasterOverrides = &KeyringOverride{
|
|
|
|
|
cdc: cdc,
|
|
|
|
|
keyringOptions: opts,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *IntegrationTestSuite) SetupSuite() {
|
|
|
|
|
// build the chain
|
|
|
|
|
s.T().Log("building chain with spec", s.spec)
|
|
|
|
@@ -64,6 +81,10 @@ func (s *IntegrationTestSuite) SetupSuite() {
|
|
|
|
|
s.user1 = interchaintest.GetAndFundTestUsers(s.T(), ctx, s.T().Name(), initBalance, s.chain)[0]
|
|
|
|
|
s.user2 = interchaintest.GetAndFundTestUsers(s.T(), ctx, s.T().Name(), initBalance, s.chain)[0]
|
|
|
|
|
s.user3 = interchaintest.GetAndFundTestUsers(s.T(), ctx, s.T().Name(), initBalance, s.chain)[0]
|
|
|
|
|
|
|
|
|
|
// create the broadcaster
|
|
|
|
|
s.T().Log("creating broadcaster")
|
|
|
|
|
s.setupBroadcaster()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *IntegrationTestSuite) TearDownSuite() {
|
|
|
|
@@ -108,7 +129,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
|
|
|
|
|
// create the MsgAuctioBid
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
bid, bundledTxs := s.CreateAuctionBidMsg(context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{
|
|
|
|
@@ -122,7 +143,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast + wait for the tx to be included in a block
|
|
|
|
|
res := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
res := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -156,7 +177,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
|
|
|
|
|
// create the MsgAuctionBid
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
bid, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: msgs[0:1],
|
|
|
|
@@ -172,24 +193,52 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
msgsToBcast = append(msgsToBcast, Tx{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
msgsToBcast = append(msgsToBcast, Tx{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: msgs[1:2],
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
regular_txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), msgsToBcast)
|
|
|
|
|
expTxs := make(chan committedTx, 2)
|
|
|
|
|
|
|
|
|
|
regular_txs := s.BroadcastTxsWithCallback(
|
|
|
|
|
context.Background(),
|
|
|
|
|
s.chain.(*cosmos.CosmosChain),
|
|
|
|
|
msgsToBcast,
|
|
|
|
|
func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
expTxs <- committedTx{tx, resp}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
close(expTxs)
|
|
|
|
|
s.Require().Len(expTxs, 2)
|
|
|
|
|
|
|
|
|
|
// get the height of the block that the bid was included in
|
|
|
|
|
var commitHeight int64
|
|
|
|
|
|
|
|
|
|
tx1 := <-expTxs
|
|
|
|
|
tx2 := <-expTxs
|
|
|
|
|
|
|
|
|
|
// determine which tx is the bid
|
|
|
|
|
if bytes.Equal(tx1.tx, regular_txs[0]) {
|
|
|
|
|
commitHeight = tx1.res.Height
|
|
|
|
|
} else {
|
|
|
|
|
commitHeight = tx2.res.Height
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if they were committed in the same height
|
|
|
|
|
if tx1.res.Height == tx2.res.Height {
|
|
|
|
|
bundledTxs = append(bundledTxs, regular_txs[1:]...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get the block at the next height
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), commitHeight)
|
|
|
|
|
|
|
|
|
|
// verify the block
|
|
|
|
|
bidTxHash := TxHash(regular_txs[0])
|
|
|
|
|
VerifyBlock(s.T(), block, 0, bidTxHash, append(bundledTxs, regular_txs[1:]...))
|
|
|
|
|
VerifyBlock(s.T(), block, 0, bidTxHash, bundledTxs)
|
|
|
|
|
|
|
|
|
|
// ensure that escrow account has the correct balance
|
|
|
|
|
escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom)
|
|
|
|
@@ -216,10 +265,10 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
}
|
|
|
|
|
// create bundle
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, txs)
|
|
|
|
|
bid, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, txs)
|
|
|
|
|
// create 2 more bundle w same txs from same user
|
|
|
|
|
bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), txs)
|
|
|
|
|
bid3, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement).Add(params.MinBidIncrement), txs)
|
|
|
|
|
bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), txs)
|
|
|
|
|
bid3, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement).Add(params.MinBidIncrement), txs)
|
|
|
|
|
|
|
|
|
|
// query height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
@@ -230,7 +279,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
height++
|
|
|
|
|
|
|
|
|
|
// broadcast all bids
|
|
|
|
|
broadcastedTxs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
broadcastedTxs := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -286,28 +335,41 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
|
|
|
|
|
// create bundle
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, txs)
|
|
|
|
|
bid, bundledTxs := s.CreateAuctionBidMsg(context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, txs)
|
|
|
|
|
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err = s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
expTxs := make(chan committedTx, 4)
|
|
|
|
|
|
|
|
|
|
// broadcast txs in the bundle to network + bundle + extra
|
|
|
|
|
broadcastedTxs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{txs[0], txs[1], {
|
|
|
|
|
broadcastedTxs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
}, {
|
|
|
|
|
User: s.user3,
|
|
|
|
|
Msgs: []sdk.Msg{banktypes.NewMsgSend(s.user3.Address(), s.user1.Address(), sdk.NewCoins(sdk.NewCoin(s.denom, math.NewInt(100))))},
|
|
|
|
|
}})
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
}},
|
|
|
|
|
func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
expTxs <- committedTx{tx, resp}
|
|
|
|
|
})
|
|
|
|
|
close(expTxs)
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
var bidTxHeight int64
|
|
|
|
|
for tx := range expTxs {
|
|
|
|
|
if bytes.Equal(tx.tx, broadcastedTxs[0]) {
|
|
|
|
|
bidTxHeight = tx.res.Height
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), bidTxHeight)
|
|
|
|
|
|
|
|
|
|
// check block
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(broadcastedTxs[2]), append(bundledTxs, broadcastedTxs[3]))
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(broadcastedTxs[0]), bundledTxs)
|
|
|
|
|
|
|
|
|
|
// check escrow account balance
|
|
|
|
|
escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom)
|
|
|
|
@@ -316,6 +378,11 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type committedTx struct {
|
|
|
|
|
tx []byte
|
|
|
|
|
res *rpctypes.ResultTx
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TestMultipleBids tests the execution of various valid auction bids in the same block. There are a few
|
|
|
|
|
// invariants that are tested:
|
|
|
|
|
//
|
|
|
|
@@ -343,7 +410,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
}
|
|
|
|
|
// create bid1
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
// create bid 2
|
|
|
|
|
msg2 := Tx{
|
|
|
|
@@ -352,36 +419,45 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
SequenceIncrement: 1,
|
|
|
|
|
}
|
|
|
|
|
// create bid2 w/ higher bid than bid1
|
|
|
|
|
bid2, bundledTxs2 := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2})
|
|
|
|
|
bid2, bundledTxs2 := s.CreateAuctionBidMsg( context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2})
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
// create channel to receive txs
|
|
|
|
|
txsCh := make(chan committedTx, 2)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids (with ample time to be committed (instead of timing out))
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid1},
|
|
|
|
|
Height: height + 2,
|
|
|
|
|
SkipInclusionCheck: true,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
txsCh <- committedTx{tx, resp}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// check txs were committed
|
|
|
|
|
require.Len(s.T(), txsCh, 2)
|
|
|
|
|
close(txsCh)
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
tx1 := <-txsCh
|
|
|
|
|
tx2 := <-txsCh
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), tx1.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid2 was included first
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs2)
|
|
|
|
|
|
|
|
|
|
// check next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+2)
|
|
|
|
|
block = Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+2))
|
|
|
|
|
block = Block(s.T(), s.chain.(*cosmos.CosmosChain), tx2.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid1 was included second
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs)
|
|
|
|
@@ -405,7 +481,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
}
|
|
|
|
|
// create bid1
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx})
|
|
|
|
|
bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx})
|
|
|
|
|
|
|
|
|
|
// create bid 2
|
|
|
|
|
tx2 := Tx{
|
|
|
|
@@ -414,30 +490,36 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
SequenceIncrement: 1,
|
|
|
|
|
}
|
|
|
|
|
// create bid2 w/ higher bid than bid1
|
|
|
|
|
bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx2})
|
|
|
|
|
bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{tx2})
|
|
|
|
|
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
expTx := make(chan committedTx, 1)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids (wait for the first to be committed)
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid1},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
ExpectFail: true,
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
expTx <- committedTx{tx, resp}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
close(expTx)
|
|
|
|
|
commitTx := <-expTx
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), commitTx.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid2 was included first
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs)
|
|
|
|
@@ -461,7 +543,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
}
|
|
|
|
|
// create bid1
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
// create bid 2
|
|
|
|
|
msg2 := Tx{
|
|
|
|
@@ -469,33 +551,39 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
Msgs: []sdk.Msg{banktypes.NewMsgSend(s.user2.Address(), s.user3.Address(), sdk.NewCoins(sdk.NewCoin(s.denom, math.NewInt(100))))},
|
|
|
|
|
SequenceIncrement: 1,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create bid2 w/ higher bid than bid1
|
|
|
|
|
bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg2})
|
|
|
|
|
bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg2})
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
expTx := make(chan committedTx, 1)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid1},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
SequenceIncrement: 1,
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
ExpectFail: true,
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
expTx <- committedTx{tx, resp}
|
|
|
|
|
})
|
|
|
|
|
close(expTx)
|
|
|
|
|
|
|
|
|
|
commitTx := <-expTx
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), commitTx.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid2 was included first
|
|
|
|
|
// check bid1 was included first
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs)
|
|
|
|
|
|
|
|
|
|
// check escrow balance
|
|
|
|
@@ -517,41 +605,49 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
}
|
|
|
|
|
// create bid1
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
// create bid2 w/ higher bid than bid1
|
|
|
|
|
bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg})
|
|
|
|
|
bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg})
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
commitTx := make(chan committedTx, 1)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
},
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid1},
|
|
|
|
|
Height: height + 2,
|
|
|
|
|
SequenceIncrement: 1,
|
|
|
|
|
ExpectFail: true,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
SkipInclusionCheck: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
commitTx <- committedTx{tx, resp}
|
|
|
|
|
})
|
|
|
|
|
close(commitTx)
|
|
|
|
|
|
|
|
|
|
expTx := <-commitTx
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), expTx.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid2 was included first
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs)
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs)
|
|
|
|
|
|
|
|
|
|
// check escrow balance
|
|
|
|
|
escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom)
|
|
|
|
|
expectedIncrement := escrowAddressIncrement(bidAmt.Add(params.MinBidIncrement).Amount, params.ProposerFee)
|
|
|
|
|
require.Equal(s.T(), escrowAcctBalanceBeforeBid+expectedIncrement, escrowAcctBalanceAfterBid)
|
|
|
|
|
|
|
|
|
|
// wait for next block for mempool to clear
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+3)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("Multiple transactions from diff. account with increasing bids but first bid has same bundle so it should fail in later block", func() {
|
|
|
|
@@ -567,40 +663,49 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
|
|
|
|
|
// create bid1
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
// create bid2 w/ higher bid than bid1
|
|
|
|
|
bid2, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg})
|
|
|
|
|
bid2, _ := s.CreateAuctionBidMsg( context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg})
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
commitTx := make(chan committedTx, 1)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
},
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid1},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
ExpectFail: true,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
SkipInclusionCheck: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
commitTx <- committedTx{tx, resp}
|
|
|
|
|
})
|
|
|
|
|
close(commitTx)
|
|
|
|
|
|
|
|
|
|
expTx := <-commitTx
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), expTx.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid2 was included first
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs)
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs)
|
|
|
|
|
|
|
|
|
|
// check escrow balance
|
|
|
|
|
escrowAcctBalanceAfterBid := QueryAccountBalance(s.T(), s.chain, escrowAddr, params.ReserveFee.Denom)
|
|
|
|
|
expectedIncrement := escrowAddressIncrement(bidAmt.Add(params.MinBidIncrement).Amount, params.ProposerFee)
|
|
|
|
|
require.Equal(s.T(), escrowAcctBalanceBeforeBid+expectedIncrement, escrowAcctBalanceAfterBid)
|
|
|
|
|
|
|
|
|
|
// wait for next block for mempool to clear
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+3)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("Multiple transactions with increasing bids and different bundles", func() {
|
|
|
|
@@ -616,7 +721,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
}
|
|
|
|
|
// create bid1
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid1, bundledTxs := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid1, bundledTxs := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
// create bid2
|
|
|
|
|
// create a second message
|
|
|
|
@@ -627,36 +732,48 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create bid2 w/ higher bid than bid1
|
|
|
|
|
bid2, bundledTxs2 := CreateAuctionBidMsg(s.T(), context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2})
|
|
|
|
|
bid2, bundledTxs2 := s.CreateAuctionBidMsg(context.Background(), s.user2, s.chain.(*cosmos.CosmosChain), bidAmt.Add(params.MinBidIncrement), []Tx{msg2})
|
|
|
|
|
// get chain height
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// make channel for committedTxs (expect 2 txs to be committed)
|
|
|
|
|
committedTxs := make(chan committedTx, 2)
|
|
|
|
|
|
|
|
|
|
// broadcast both bids
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid1},
|
|
|
|
|
Height: height + 2,
|
|
|
|
|
SkipInclusionCheck: true,
|
|
|
|
|
Height: height + 4,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{bid2},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
committedTxs <- committedTx{
|
|
|
|
|
tx: tx,
|
|
|
|
|
res: resp,
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// close the channel when finished
|
|
|
|
|
close(committedTxs)
|
|
|
|
|
|
|
|
|
|
// expect 2 txs
|
|
|
|
|
tx1 := <-committedTxs
|
|
|
|
|
tx2 := <-committedTxs
|
|
|
|
|
|
|
|
|
|
// query next block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), tx1.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid2 was included first
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[1]), bundledTxs2)
|
|
|
|
|
|
|
|
|
|
// query next block and check tx inclusion
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+2)
|
|
|
|
|
block = Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+2))
|
|
|
|
|
block = Block(s.T(), s.chain.(*cosmos.CosmosChain), tx2.res.Height)
|
|
|
|
|
|
|
|
|
|
// check bid1 was included second
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTxs)
|
|
|
|
@@ -680,11 +797,11 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
SequenceIncrement: 2,
|
|
|
|
|
}
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
// wrap bidTx in another tx
|
|
|
|
|
wrappedBid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
wrappedBid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -696,7 +813,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{wrappedBid},
|
|
|
|
@@ -714,13 +831,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
SequenceIncrement: 2,
|
|
|
|
|
}
|
|
|
|
|
bidAmt := sdk.NewCoin(s.denom, math.NewInt(1000000000000000000))
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("Invalid bid that is attempting to front-run/sandwich", func() {
|
|
|
|
@@ -741,13 +858,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg, msg2, msg3})
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg, msg2, msg3})
|
|
|
|
|
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("Invalid bid that includes an invalid bundle tx", func() {
|
|
|
|
@@ -758,13 +875,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
SequenceIncrement: 2,
|
|
|
|
|
}
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -784,13 +901,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
|
|
|
|
|
// create bid smaller than reserve
|
|
|
|
|
bidAmt := sdk.NewCoin(s.denom, math.NewInt(0))
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("Invalid auction bid with too many transactions in the bundle", func() {
|
|
|
|
@@ -807,13 +924,13 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
|
|
|
|
|
// create bid smaller than reserve
|
|
|
|
|
bidAmt := sdk.NewCoin(s.denom, math.NewInt(0))
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, msgs)
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, msgs)
|
|
|
|
|
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, height+1, true, []sdk.Msg{bid}...)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("invalid auction bid that has an invalid timeout", func() {
|
|
|
|
@@ -826,10 +943,10 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
|
|
|
|
|
// create bid smaller than reserve
|
|
|
|
|
bidAmt := sdk.NewCoin(s.denom, math.NewInt(0))
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{msg})
|
|
|
|
|
|
|
|
|
|
// broadcast wrapped bid, and expect a failure
|
|
|
|
|
SimulateTx(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, 0, true, []sdk.Msg{bid}...)
|
|
|
|
|
s.SimulateTx(context.Background(), s.chain.(*cosmos.CosmosChain), s.user1, 0, true, []sdk.Msg{bid}...)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
s.Run("Invalid bid that includes valid transactions that are in the mempool", func() {
|
|
|
|
@@ -842,7 +959,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
|
|
|
|
|
// create the MsgAuctioBid (this should fail b.c same tx is repeated twice)
|
|
|
|
|
bidAmt := params.ReserveFee
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(s.T(), context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg( context.Background(), s.user1, s.chain.(*cosmos.CosmosChain), bidAmt, []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
|
Msgs: []sdk.Msg{
|
|
|
|
@@ -859,7 +976,7 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
// broadcast + wait for the tx to be included in a block
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
txs := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -905,7 +1022,7 @@ func (s *IntegrationTestSuite) TestFreeLane() {
|
|
|
|
|
balanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user1.FormattedAddress(), s.denom)
|
|
|
|
|
|
|
|
|
|
// create a free tx (MsgDelegate), broadcast and wait for commit
|
|
|
|
|
BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{
|
|
|
|
@@ -929,7 +1046,7 @@ func (s *IntegrationTestSuite) TestFreeLane() {
|
|
|
|
|
user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom)
|
|
|
|
|
|
|
|
|
|
// user1 submits a free-tx, user2 submits a normal tx
|
|
|
|
|
BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
s.BroadcastTxs(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{
|
|
|
|
@@ -968,7 +1085,7 @@ func (s *IntegrationTestSuite) TestFreeLane() {
|
|
|
|
|
user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom)
|
|
|
|
|
|
|
|
|
|
// user1 submits a free-tx, user2 submits a free tx
|
|
|
|
|
BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{
|
|
|
|
@@ -1012,8 +1129,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom)
|
|
|
|
|
|
|
|
|
|
// create free-tx, bid-tx, and normal-tx\
|
|
|
|
|
bid, bundledTx := CreateAuctionBidMsg(
|
|
|
|
|
s.T(),
|
|
|
|
|
bid, bundledTx := s.CreateAuctionBidMsg(
|
|
|
|
|
context.Background(),
|
|
|
|
|
s.user1,
|
|
|
|
|
s.chain.(*cosmos.CosmosChain),
|
|
|
|
@@ -1036,11 +1152,13 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
committedTxs := make(chan committedTx, 3)
|
|
|
|
|
|
|
|
|
|
txs := s.BroadcastTxsWithCallback(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
|
Height: height + 1,
|
|
|
|
|
Height: height + 3,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
User: s.user2,
|
|
|
|
@@ -1063,13 +1181,23 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}, func(tx []byte, resp *rpctypes.ResultTx) {
|
|
|
|
|
committedTxs <- committedTx{tx: tx, res: resp}
|
|
|
|
|
})
|
|
|
|
|
close(committedTxs)
|
|
|
|
|
|
|
|
|
|
// check block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
// find height of committed tx
|
|
|
|
|
var committedHeight int64
|
|
|
|
|
for tx := range committedTxs {
|
|
|
|
|
if bytes.Equal(tx.tx, txs[0]) {
|
|
|
|
|
committedHeight = tx.res.Height
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), append(bundledTx, txs[1:]...))
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), committedHeight)
|
|
|
|
|
|
|
|
|
|
VerifyBlock(s.T(), block, 0, TxHash(txs[0]), bundledTx)
|
|
|
|
|
|
|
|
|
|
// check user2 balance expect no fee deduction
|
|
|
|
|
user2BalanceAfter := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom)
|
|
|
|
@@ -1080,8 +1208,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
user2BalanceBefore := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom)
|
|
|
|
|
user1Balance := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user1.FormattedAddress(), s.denom)
|
|
|
|
|
// create free-tx, bid-tx, and normal-tx\
|
|
|
|
|
bid, _ := CreateAuctionBidMsg(
|
|
|
|
|
s.T(),
|
|
|
|
|
bid, _ := s.CreateAuctionBidMsg(
|
|
|
|
|
context.Background(),
|
|
|
|
|
s.user1,
|
|
|
|
|
s.chain.(*cosmos.CosmosChain),
|
|
|
|
@@ -1115,7 +1242,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user1,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -1145,12 +1272,6 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// check block
|
|
|
|
|
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)
|
|
|
|
|
block := Block(s.T(), s.chain.(*cosmos.CosmosChain), int64(height+1))
|
|
|
|
|
|
|
|
|
|
VerifyBlock(s.T(), block, 0, "", txs[1:])
|
|
|
|
|
|
|
|
|
|
// check user2 balance expect no fee deduction
|
|
|
|
|
user2BalanceAfter := QueryAccountBalance(s.T(), s.chain.(*cosmos.CosmosChain), s.user2.FormattedAddress(), s.denom)
|
|
|
|
|
require.Equal(s.T(), user2BalanceBefore, user2BalanceAfter+delegation.Amount.Int64())
|
|
|
|
@@ -1171,8 +1292,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
GasPrice: 10,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bid, bundledTx := CreateAuctionBidMsg(
|
|
|
|
|
s.T(),
|
|
|
|
|
bid, bundledTx := s.CreateAuctionBidMsg(
|
|
|
|
|
context.Background(),
|
|
|
|
|
s.user3,
|
|
|
|
|
s.chain.(*cosmos.CosmosChain),
|
|
|
|
@@ -1196,7 +1316,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
txs := s.BroadcastTxs(context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user3,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
@@ -1248,8 +1368,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
|
|
|
|
|
// create bid-tx w/ user3 DelegateTx
|
|
|
|
|
|
|
|
|
|
bid, bundledTx := CreateAuctionBidMsg(
|
|
|
|
|
s.T(),
|
|
|
|
|
bid, bundledTx := s.CreateAuctionBidMsg(
|
|
|
|
|
context.Background(),
|
|
|
|
|
s.user3,
|
|
|
|
|
s.chain.(*cosmos.CosmosChain),
|
|
|
|
@@ -1273,7 +1392,7 @@ func (s *IntegrationTestSuite) TestLanes() {
|
|
|
|
|
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
|
|
|
|
|
require.NoError(s.T(), err)
|
|
|
|
|
|
|
|
|
|
txs := BroadcastTxs(s.T(), context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
txs := s.BroadcastTxs( context.Background(), s.chain.(*cosmos.CosmosChain), []Tx{
|
|
|
|
|
{
|
|
|
|
|
User: s.user3,
|
|
|
|
|
Msgs: []sdk.Msg{bid},
|
|
|
|
|