Skip to content

Commit

Permalink
Add test for mempool size parity
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Warehime committed Dec 11, 2023
1 parent 7d8a695 commit 7918c1c
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/integration/block_sdk_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"context"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"math/rand"
"time"

Expand Down Expand Up @@ -1423,6 +1424,66 @@ func (s *IntegrationTestSuite) TestNetwork() {
}
}
})
s.Run("app-side mempool mirrors consensus-side mempool", func() {
for {
select {
case <-amountToTest.C:
return
default:
height, err := s.chain.(*cosmos.CosmosChain).Height(context.Background())
s.NoError(err)
WaitForHeight(s.T(), s.chain.(*cosmos.CosmosChain), height+1)

s.T().Logf("height: %d", height+1)

txs := []Tx{}

for i := 0; i < numTxs; i++ {
for _, user := range s.fuzzusers[0:3] {
bid := rand.Int63n(1000000)
bidAmount := sdk.NewCoin(s.denom, math.NewInt(bid))

bidTx := s.CreateDummyAuctionBidTx(
height+2,
user,
bidAmount,
)
txs = append(txs, bidTx)
}
}

for i := 0; i < numTxs; i++ {
for _, user := range s.fuzzusers[3:6] {
sequenceOffset := uint64(i)

freeTx := s.CreateDummyFreeTx(user, validators[0], delegation, sequenceOffset)
txs = append(txs, freeTx)

}
}

for i := 0; i < numTxs; i++ {
for _, user := range s.fuzzusers[6:10] {
fee := rand.Int63n(100000)
sequenceOffset := uint64(i)
normalTx := s.CreateDummyNormalTx(user, s.user1, sendAmount, sequenceOffset, fee)
txs = append(txs, normalTx)
}
}

s.BroadcastTxs(context.Background(), s.chain.(*cosmos.CosmosChain), txs)
singleNode := s.chain.(*cosmos.CosmosChain).GetNode()
_ = testutil.WaitForBlocksUtil(1, func(_ int) error {
cometMempool, err := singleNode.Client.NumUnconfirmedTxs(context.Background())
s.Require().NoError(err)
appMempool, err := QueryMempool(s.T(), singleNode.Chain)
s.Require().NoError(err)
s.Require().Equal(cometMempool.Total, appMempool.Size())
return nil
})
}
}
})

// Wait for 1 minute for the network to stabilize
amountToTest.Reset(1 * time.Minute)
Expand Down

0 comments on commit 7918c1c

Please sign in to comment.