fuzz: Move global node id counter along with other global state

The global m_headers_presync_stats is not reset in ResetAndInitialize.
This may lead to non-determinism.

Fix it by incrementing the global node id counter instead.

Without this patch, the tool would report a diff:

cargo run --manifest-path ./contrib/devtools/deterministic-fuzz-coverage/Cargo.toml -- $PWD/bld-cmake/ $PWD/../qa-assets/fuzz_corpora/ p2p_headers_presync 32

...
  2587|  3.73k|            if (best_it == m_headers_presync_stats.end()) {
   ------------------
-  |  Branch (2587:17): [True: 80, False: 3.65k]
+  |  Branch (2587:17): [True: 73, False: 3.66k]
   ------------------
...
This commit is contained in:
MarcoFalke 2025-04-07 14:02:01 +02:00
parent fa98455e4b
commit faf2d512c5
No known key found for this signature in database

View file

@ -54,7 +54,7 @@ void HeadersSyncSetup::ResetAndInitialize()
auto& connman = static_cast<ConnmanTestMsg&>(*m_node.connman); auto& connman = static_cast<ConnmanTestMsg&>(*m_node.connman);
connman.StopNodes(); connman.StopNodes();
NodeId id{0}; static NodeId id{0};
std::vector<ConnectionType> conn_types = { std::vector<ConnectionType> conn_types = {
ConnectionType::OUTBOUND_FULL_RELAY, ConnectionType::OUTBOUND_FULL_RELAY,
ConnectionType::BLOCK_RELAY, ConnectionType::BLOCK_RELAY,