fuzz: connman: add network activity invariants
What changed, and why it matters
This commit only changes a fuzz test file. A fuzz test is an automated testing harness that throws random inputs at code to find bugs. The change adds an assertion that after setting network activity on or off, reading the value back matches what was set. It removes a redundant read at the end of the test. There is no change to production Bitcoin networking code, so this does not fix or introduce a security issue in the live software.
No action required. This is a benign test-only improvement. Reviewers may optionally verify that SetNetworkActive/GetNetworkActive are already covered by other tests, but the change itself is safe.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In src/test/fuzz/connman.cpp, the fuzz target’s SetNetworkActive action now captures the consumed boolean and immediately asserts that connman.GetNetworkActive() equals the value just passed to SetNetworkActive(). The final standalone (void)connman.GetNetworkActive() call is removed because the invariant is now checked inline. This is a test-hardening change: it strengthens the fuzz oracle by validating a simple getter/setter round-trip invariant. It does not modify CConnman implementation or any consensus/networking behavior.
Changed components
src/test/fuzz/connman.cppInspect captured patch +3 / −2
diff --git a/src/test/fuzz/connman.cpp b/src/test/fuzz/connman.cpp
index 7ac4f3b8..0758dcfe 100644
--- a/src/test/fuzz/connman.cpp
+++ b/src/test/fuzz/connman.cpp
@@ -183,7 +183,9 @@ FUZZ_TARGET(connman, .init = initialize_connman)
connman.RemoveAddedNode(random_string);
},
[&] {
- connman.SetNetworkActive(fuzzed_data_provider.ConsumeBool());
+ const auto set_active{fuzzed_data_provider.ConsumeBool()};
+ connman.SetNetworkActive(set_active);
+ assert(connman.GetNetworkActive() == set_active);
},
[&] {
connman.SetTryNewOutboundPeer(fuzzed_data_provider.ConsumeBool());
@@ -247,7 +249,6 @@ FUZZ_TARGET(connman, .init = initialize_connman)
assert(connman.GetMaxOutboundTarget() == max_outbound_limit);
(void)connman.GetMaxOutboundTimeframe();
(void)connman.GetMaxOutboundTimeLeftInCycle();
- (void)connman.GetNetworkActive();
std::vector<CNodeStats> stats;
connman.GetNodeStats(stats);
(void)connman.GetOutboundTargetBytesLeft();
Why this scored 12/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.