fuzz: connman: add outbound-bytes invariants
What changed, and why it matters
This commit only adds extra consistency checks (assertions) inside an existing fuzz test for Bitcoin Core's network connection manager. It does not change production code, network behavior, or wallet logic. There is no user-facing bug fix or security patch here.
No action required; this is a test-hardening change. Review as part of normal fuzz-test maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change is confined to src/test/fuzz/connman.cpp. It records initial values of GetTotalBytesRecv()/GetTotalBytesSent() and adds asserts that byte counters never decrease and that outbound byte-limit helpers stay within expected bounds. These are test-only invariants for the fuzzing harness; no CConnman implementation code is modified.
Changed components
src/test/fuzz/connman.cppInspect captured patch +14 / −5
diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp
index 214ba14f..bf34538b 100644
--- a/src/test/fuzz/connman.cpp
+++ b/src/test/fuzz/connman.cpp
@@ -101,6 +101,9 @@ FUZZ_TARGET(connman, .init = initialize_connman)
connman.Init(options);
+ const uint64_t total_bytes_recv_initial{connman.GetTotalBytesRecv()};
+ const uint64_t total_bytes_sent_initial{connman.GetTotalBytesSent()};
+
CNetAddr random_netaddr;
CAddress random_address;
CNode random_node = ConsumeNode(fuzzed_data_provider);
@@ -269,13 +272,19 @@ FUZZ_TARGET(connman, .init = initialize_connman)
(void)connman.GetExtraFullOutboundCount();
assert(connman.GetLocalServices() == local_services);
assert(connman.GetMaxOutboundTarget() == max_outbound_limit);
- (void)connman.GetMaxOutboundTimeframe();
- (void)connman.GetMaxOutboundTimeLeftInCycle();
+ const auto time_left_in_cycle{connman.GetMaxOutboundTimeLeftInCycle()};
std::vector<CNodeStats> stats;
connman.GetNodeStats(stats);
- (void)connman.GetOutboundTargetBytesLeft();
- (void)connman.GetTotalBytesRecv();
- (void)connman.GetTotalBytesSent();
+ const auto bytes_left{connman.GetOutboundTargetBytesLeft()};
+ assert(bytes_left <= max_outbound_limit);
+ if (max_outbound_limit == 0) {
+ assert(bytes_left == 0);
+ assert(time_left_in_cycle == std::chrono::seconds{0});
+ assert(!connman.OutboundTargetReached(/*historicalBlockServingLimit=*/false));
+ assert(!connman.OutboundTargetReached(/*historicalBlockServingLimit=*/true));
+ }
+ assert(connman.GetTotalBytesRecv() >= total_bytes_recv_initial);
+ assert(connman.GetTotalBytesSent() >= total_bytes_sent_initial);
(void)connman.GetTryNewOutboundPeer();
assert(connman.GetUseAddrmanOutgoing() == use_addrman_outgoing);
(void)connman.ASMapHealthCheck();
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.