test: cover disconnect on private broadcast peer with relay=false #35681

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2026-07-test-private-broadcast changing 1 files +27 −0
  1. brunoerg commented at 9:33 PM on July 7, 2026: contributor

    Currently, there is no test case to verify the disconnection of a private broadcast connection when the peer does not support transaction relay. This PR addresses it.

    Can be tested with:

    diff --git a/src/net_processing.cpp b/src/net_processing.cpp
    index 27f0a63c55..5d9a8f9c06 100644
    --- a/src/net_processing.cpp
    +++ b/src/net_processing.cpp
    @@ -3741,7 +3741,7 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
                 } else {
                     LogDebug(BCLog::PRIVBROADCAST, "Disconnecting: does not support transaction relay (connected in vain), %s",
                              pfrom.LogPeer());
    -                pfrom.fDisconnect = true;
    +                pfrom.fDisconnect = false;
                 }
                 return;
             }
    
  2. DrahtBot added the label Tests on Jul 7, 2026
  3. DrahtBot commented at 9:33 PM on July 7, 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/35681.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process. A summary of reviews will appear here.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. brunoerg marked this as ready for review on Jul 7, 2026
  5. test: cover disconnect on private broadcast peer with relay=false 1fc9277a1c
  6. in test/functional/p2p_private_broadcast.py:397 in f748da22b7
     392 | @@ -379,6 +393,19 @@ def set_tx_returner_and_other():
     393 |              "0" * 64,
     394 |          )
     395 |  
     396 | +        self.log.info("Checking that a private broadcast destination signaling relay=false gets disconnected")
     397 | +        with self.destinations_lock:
    


    w0xlt commented at 9:35 PM on July 9, 2026:

    It may be safer to set self.trigger_no_relay_peer inside the assert_debug_log context.

    diff --git a/test/functional/p2p_private_broadcast.py b/test/functional/p2p_private_broadcast.py
    index 739eb03c68..054058e946 100755
    --- a/test/functional/p2p_private_broadcast.py
    +++ b/test/functional/p2p_private_broadcast.py
    @@ -394,12 +394,12 @@ class P2PPrivateBroadcast(BitcoinTestFramework):
             )
     
             self.log.info("Checking that a private broadcast destination signaling relay=false gets disconnected")
    -        with self.destinations_lock:
    -            self.no_relay_peer = None
    -            self.trigger_no_relay_peer = True
             tx_no_relay = wallet.create_self_transfer()
             disconnect_msg = "Disconnecting: does not support transaction relay (connected in vain)"
             with tx_originator.assert_debug_log(expected_msgs=[disconnect_msg]):
    +            with self.destinations_lock:
    +                self.no_relay_peer = None
    +                self.trigger_no_relay_peer = True
                 tx_originator.sendrawtransaction(hexstring=tx_no_relay["hex"], maxfeerate=0.1)
                 self.wait_until(lambda: self.no_relay_peer is not None)
                 self.no_relay_peer.wait_until(lambda: self.no_relay_peer.message_count["version"] == 1, check_connected=False)
    

    brunoerg commented at 5:53 PM on July 10, 2026:

    Yes, it would narrow the race window. Going to address it.

  7. brunoerg force-pushed on Jul 10, 2026
  8. brunoerg commented at 5:59 PM on July 10, 2026: contributor

    Force-pushed addressing #35681 (review)

Labels

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-07-11 18:51 UTC

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