From 2cb7e99deee1017a6edd94d82de556895138361d Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Thu, 5 Feb 2026 09:45:20 +0100 Subject: [PATCH] test: also reset CConnman::m_private_broadcast in tests Member variables of `CConnman::m_private_broadcast` (introduced in https://github.com/bitcoin/bitcoin/pull/29415) could influence the tests which creates non-determinism if the same instance of `CConnman` is used for repeated test iterations. So, reset the state of `CConnman::m_private_broadcast` from `ConnmanTestMsg::Reset()`. Currently this affects the fuzz tests `process_message` and `process_messages`. Reported in https://github.com/bitcoin/bitcoin/issues/34476#issuecomment-3849088794 --- src/net.h | 4 +++- src/test/util/net.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/net.h b/src/net.h index 1e4e9124e9f..523b596f4c7 100644 --- a/src/net.h +++ b/src/net.h @@ -1241,7 +1241,7 @@ public: /// Wait for the number of needed connections to become greater than 0. void NumToOpenWait() const; - private: + protected: /** * Check if private broadcast can be done to IPv4 or IPv6 peers and if so via which proxy. * If private broadcast connections should not be opened to IPv4 or IPv6, then this will @@ -1251,6 +1251,8 @@ public: /// Number of `ConnectionType::PRIVATE_BROADCAST` connections to open. std::atomic_size_t m_num_to_open{0}; + + friend struct ConnmanTestMsg; } m_private_broadcast; bool CheckIncomingNonce(uint64_t nonce); diff --git a/src/test/util/net.cpp b/src/test/util/net.cpp index 160ef9792bd..a1c588b6e50 100644 --- a/src/test/util/net.cpp +++ b/src/test/util/net.cpp @@ -84,6 +84,8 @@ void ConnmanTestMsg::Reset() { ResetAddrCache(); ResetMaxOutboundCycle(); + m_private_broadcast.m_outbound_tor_ok_at_least_once.store(false); + m_private_broadcast.m_num_to_open.store(0); } void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, std::span msg_bytes, bool& complete) const