Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#31811: test: test_inv_block, use mocktime inste…
Browse files Browse the repository at this point in the history
…ad of waiting

2706c5b test: test_inv_block, use mocktime instead of waiting (Greg Sanders)

Pull request description:

  Performance issue reported in bitcoin/bitcoin#31437 (comment)

  It seems that code as-is waits for wall-clock time to pass to synchronize mempools. Locally, sometimes the subtest takes a couple seconds, sometimes it takes an additional minute.

  Just use mocktime?

ACKs for top commit:
  sr-gi:
    tACK [2706c5b](bitcoin/bitcoin@2706c5b)
  rishkwal:
    tACK 2706c5b
  Prabhat1308:
    tACK [2706c5b](bitcoin/bitcoin@2706c5b)

Tree-SHA512: 561fe3d67282c67e1ed7dd5eeb137964c083d498534ea5f749f3d782e73a3f47d23faee6cca39866eaba770fda7b7d60a9f740f16bdb451d6a5e9105417cb158
  • Loading branch information
glozow committed Feb 7, 2025
2 parents 81eb6cc + 2706c5b commit fb0ada9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/functional/p2p_tx_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def test_inv_block(self):
tx = self.wallet.create_self_transfer()
wtxid = int(tx['wtxid'], 16)

self.nodes[0].setmocktime(int(time.time()))

self.log.info(
"Announce the transaction to all nodes from all {} incoming peers, but never send it".format(NUM_INBOUND))
msg = msg_inv([CInv(t=MSG_WTX, h=wtxid)])
Expand All @@ -125,7 +127,10 @@ def test_inv_block(self):
assert self.nodes[1].getpeerinfo()[0]['inbound'] == False
timeout = 2 + INBOUND_PEER_TX_DELAY + GETDATA_TX_INTERVAL
self.log.info("Tx should be received at node 1 after {} seconds".format(timeout))
self.sync_mempools(timeout=timeout)
self.nodes[0].bumpmocktime(timeout)
self.sync_mempools()

self.nodes[0].setmocktime(0)

def test_in_flight_max(self):
self.log.info("Test that we don't load peers with more than {} transaction requests immediately".format(MAX_GETDATA_IN_FLIGHT))
Expand Down

0 comments on commit fb0ada9

Please sign in to comment.