test: Add missing test case for getdata requests from blocks-only peers #35553

pull roqqit wants to merge 1 commits into bitcoin:master from roqqit:blocksonly-getdata-test changing 1 files +11 −1
  1. roqqit commented at 8:54 PM on June 17, 2026: contributor

    ProcessGetData starts by eagerly processing getdata requests. In this loop, a special case checks for peers that have not requested transaction announcements (ie blocksonly) and ignores those requests. This test prevents regressions for that special case, which is currently not covered by existing tests.

  2. test: Add missing test case for getdata requests from blocks-only peers 278710a88d
  3. DrahtBot added the label Tests on Jun 17, 2026
  4. DrahtBot commented at 8:54 PM on June 17, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35553.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK sedited, nebula-21, maflcko, achow101

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. pinheadmz commented at 8:57 PM on June 17, 2026: member

    Can you explain a bit more about what you're doing with this test? How did you discover the problem? Did you try any other approaches first? Is there an open issue related to the patch? What exact code path was missing from coverage?

    Please try to make reviewer work easier by providing more context.

  6. roqqit commented at 4:05 AM on June 18, 2026: contributor

    I have updated the PR description to make it more clear.

  7. maflcko commented at 4:53 AM on June 18, 2026: member

    The burden to show the missing (and gained) coverage is on the pull author. You'll have to produce a mutation showing this.

  8. sedited approved
  9. sedited commented at 10:50 AM on July 24, 2026: contributor

    ACK 278710a88d8f7aaca6897984caaaa39fec6d9ef3

    Corecheck seems to report that this does cover the case in net_processing.

  10. in test/functional/p2p_blocksonly.py:96 in 278710a88d
      92 | @@ -93,6 +93,16 @@ def blocks_relay_conn_tests(self):
      93 |          assert_equal(self.nodes[0].getpeerinfo()[0]['relaytxes'], False)
      94 |          self.check_p2p_inv_violation(conn)
      95 |  
      96 | +        self.log.info(
    


    nebula-21 commented at 11:57 AM on July 29, 2026:
            self.log.info("Check that getdata(tx) from a block-relay-only connection is ignored")
    

    nebula-21 commented at 12:40 PM on July 29, 2026:

    nit: this could fit on one line

  11. in test/functional/p2p_blocksonly.py:99 in 278710a88d
      92 | @@ -93,6 +93,16 @@ def blocks_relay_conn_tests(self):
      93 |          assert_equal(self.nodes[0].getpeerinfo()[0]['relaytxes'], False)
      94 |          self.check_p2p_inv_violation(conn)
      95 |  
      96 | +        self.log.info(
      97 | +            "Check that getdata(tx) from a block-relay-only connection is ignored"
      98 | +        )
      99 | +        conn = self.nodes[0].add_outbound_p2p_connection(
    


    nebula-21 commented at 12:40 PM on July 29, 2026:
            conn = self.nodes[0].add_outbound_p2p_connection(P2PInterface(), p2p_idx=0, connection_type="block-relay-only")
    

    nebula-21 commented at 12:40 PM on July 29, 2026:

    nit: this could fit on one line

  12. nebula-21 commented at 12:52 PM on July 29, 2026: contributor

    ACK 278710a88d8f7aaca6897984caaaa39fec6d9ef3

    Tested with this diff:

    diff --git a/src/net_processing.cpp b/src/net_processing.cpp
    index c01f93c21a..0a8545f7f4 100644
    --- a/src/net_processing.cpp
    +++ b/src/net_processing.cpp
    @@ -2568,7 +2568,6 @@ void PeerManagerImpl::ProcessGetData(CNode& pfrom, Peer& peer, const std::atomic
             if (tx_relay == nullptr) {
                 // Ignore GETDATA requests for transactions from block-relay-only
                 // peers and peers that asked us not to announce transactions.
    -            continue;
             }
     
             if (auto tx{FindTxForGetData(*tx_relay, ToGenTxid(inv))}) {
    

    <details> <summary>Exec details</summary>

    build/test/functional/p2p_blocksonly.py 
    2026-07-29T10:02:03.823735Z TestFramework (INFO): PRNG seed is: 6360798075986940297
    2026-07-29T10:02:03.874479Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_xhb76so3
    2026-07-29T10:02:04.156389Z TestFramework (INFO): Tests with node running in -blocksonly mode
    2026-07-29T10:02:04.258523Z TestFramework (INFO): Check that txs from P2P are rejected and result in disconnect
    2026-07-29T10:02:04.364015Z TestFramework (INFO): Check that tx invs also violate the protocol
    2026-07-29T10:02:04.566740Z TestFramework (INFO): Check that txs from rpc are not rejected and relayed to other peers
    2026-07-29T10:02:07.931112Z TestFramework (INFO): Restarting node 0 with relay permission and blocksonly
    2026-07-29T10:02:08.490330Z TestFramework (INFO): Check that the tx from first_peer with relay-permission is relayed to others (ie.second_peer)
    2026-07-29T10:02:08.490613Z TestFramework (INFO): Check that the peer with relay-permission is still connected after sending the transaction
    2026-07-29T10:02:10.698464Z TestFramework (INFO): Relay-permission peer's transaction is accepted and relayed
    2026-07-29T10:02:10.752717Z TestFramework (INFO): Tests with node in normal mode with block-relay-only connections
    2026-07-29T10:02:11.308754Z TestFramework (INFO): Check that txs from P2P are rejected and result in disconnect
    2026-07-29T10:02:11.411118Z TestFramework (INFO): Tests with node in normal mode with block-relay-only connection, sending an inv
    2026-07-29T10:02:11.562710Z TestFramework (INFO): Check that tx-invs from P2P are rejected and result in disconnect
    2026-07-29T10:02:11.663939Z TestFramework (INFO): Check that getdata(tx) from a block-relay-only connection is ignored
    2026-07-29T10:02:12.188823Z TestFramework.p2p (WARNING): Connection lost to 127.0.0.1:56320 due to [Errno 104] Connection reset by peer
    2026-07-29T10:02:12.216114Z TestFramework (ERROR): Unexpected exception:
    Traceback (most recent call last):
      File "/home/bitcoin/test/functional/test_framework/test_framework.py", line 144, in main
        self.run_test()
      File "/home/bitcoin/build/test/functional/p2p_blocksonly.py", line 25, in run_test
        self.blocks_relay_conn_tests()
      File "/home/bitcoin/build/test/functional/p2p_blocksonly.py", line 102, in blocks_relay_conn_tests
        conn.send_and_ping(msg_getdata([CInv(t=MSG_WTX, h=0x12345)]))
      File "/home/bitcoin/test/functional/test_framework/p2p.py", line 712, in send_and_ping
        self.sync_with_ping(timeout=timeout)
      File "/home/bitcoin/test/functional/test_framework/p2p.py", line 725, in sync_with_ping
        self.wait_until(test_function, timeout=timeout)
      File "/home/bitcoin/test/functional/test_framework/p2p.py", line 610, in wait_until
        wait_until_helper_internal(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor, check_interval=check_interval)
      File "/home/bitcoin/test/functional/test_framework/util.py", line 440, in wait_until_helper_internal
        if predicate():
      File "/home/bitcoin/test/functional/test_framework/p2p.py", line 607, in test_function
        assert self.is_connected
    AssertionError
    2026-07-29T10:02:12.268166Z TestFramework (INFO): Not stopping nodes as test failed. The dangling processes will be cleaned up later.
    2026-07-29T10:02:12.268255Z TestFramework (WARNING): Not cleaning up dir /tmp/bitcoin_func_test_xhb76so3
    2026-07-29T10:02:12.268296Z TestFramework (ERROR): Test failed. Test logging available at /tmp/bitcoin_func_test_xhb76so3/test_framework.log
    2026-07-29T10:02:12.268401Z TestFramework (ERROR): 
    2026-07-29T10:02:12.268486Z TestFramework (ERROR): Hint: Call /home/bitcoin/test/functional/combine_logs.py '/tmp/bitcoin_func_test_xhb76so3' to consolidate all logs
    2026-07-29T10:02:12.268523Z TestFramework (ERROR): 
    2026-07-29T10:02:12.268555Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
    2026-07-29T10:02:12.268606Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
    2026-07-29T10:02:12.268643Z TestFramework (ERROR): 
    [node 0] Cleaning up leftover process
    

    </details>

    The same diff passes all the tests previous to this PR.

  13. maflcko commented at 2:03 PM on July 29, 2026: member

    lgtm ACK 278710a88d8f7aaca6897984caaaa39fec6d9ef3

  14. achow101 commented at 8:18 PM on July 29, 2026: member

    ACK 278710a88d8f7aaca6897984caaaa39fec6d9ef3

  15. achow101 merged this on Jul 29, 2026
  16. achow101 closed this on Jul 29, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-11 10:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me