Skip to content

Commit

Permalink
Merge bitcoin#31759: test: fixes p2p_ibd_txrelay wait time
Browse files Browse the repository at this point in the history
1973a9e test: fixes p2p_ibd_txrelay wait time (Sergi Delgado Segura)

Pull request description:

  `p2p_ibd_txrelay` expects no GETDATA to have been received by a peer after announcing a transaction. The reason is that the node is doing IBD, so transaction requests are not replied to. However, the way this is checked is wrong, and the check will pass even if the node **was not** in IBD.

  This is due to the mocktime not being properly initialized, so the check is always performed earlier than it should, making it impossible for the request to be there.

  This can be checked by modifying the test so the peer **is not doing IBD**, and checking how the test succeeds on that assert (even though it fails later on, given the nature of the test):

  ```diff
  index 882f5b5c13..3a69ae5860 100755
  --- a/test/functional/p2p_ibd_txrelay.py
  +++ b/test/functional/p2p_ibd_txrelay.py
  @@ -34,7 +34,7 @@ NORMAL_FEE_FILTER = Decimal(100) / COIN

   class P2PIBDTxRelayTest(BitcoinTestFramework):
       def set_test_params(self):
  -        self.setup_clean_chain = True
  +        # self.setup_clean_chain = True
           self.num_nodes = 2
           self.extra_args = [
               ["-minrelaytxfee={}".format(NORMAL_FEE_FILTER)],
  @@ -43,9 +43,11 @@ class P2PIBDTxRelayTest(BitcoinTestFramework):

       def run_test(self):
           self.log.info("Check that nodes set minfilter to MAX_MONEY while still in IBD")
  -        for node in self.nodes:
  -            assert node.getblockchaininfo()['initialblockdownload']
  -            self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
  +        # for node in self.nodes:
  +        #     assert node.getblockchaininfo()['initialblockdownload']
  +        #     self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))
  ```

ACKs for top commit:
  i-am-yuvi:
    ACK 1973a9e
  glozow:
    ACK 1973a9e

Tree-SHA512: c4b3afe9927c5480671ebf5c1f6ee5fc7e3aeefeb13c210fa83587a6c126e1a8e40ad8e46587537d0f4bf06a36bbf2310ca065d685d4d9286e5a446b8d5b2235
  • Loading branch information
glozow committed Feb 6, 2025
2 parents ae9eaa0 + 1973a9e commit 82ba505
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/functional/p2p_ibd_txrelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ def run_test(self):
assert node.getblockchaininfo()['initialblockdownload']
self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))

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

self.log.info("Check that nodes don't send getdatas for transactions while still in IBD")
peer_inver = self.nodes[0].add_p2p_connection(P2PDataStore())
txid = 0xdeadbeef
peer_inver.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=txid)]))
# The node should not send a getdata, but if it did, it would first delay 2 seconds
self.nodes[0].setmocktime(int(time.time() + NONPREF_PEER_TX_DELAY))
self.nodes[0].bumpmocktime(NONPREF_PEER_TX_DELAY)
peer_inver.sync_with_ping()
with p2p_lock:
assert txid not in peer_inver.getdata_requests
Expand Down

0 comments on commit 82ba505

Please sign in to comment.