test: add ConnmanTestMsg convenience method Reset()
What changed, and why it matters
This commit is a minor test-only code cleanup. It adds a single convenience method called Reset() to a test helper class, so that fuzz tests can call one method instead of two. It does not change any production Bitcoin networking code and has no security relevance for live nodes.
No action required. This is a benign test refactoring commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch introduces ConnmanTestMsg::Reset() in src/test/util/net.cpp/net.h, which simply calls ResetAddrCache() and ResetMaxOutboundCycle(). Two fuzz targets (process_message and process_messages) are updated to use this new method. No production code is modified; the change is purely refactoring of test infrastructure.
Changed components
src/test/util/net.hsrc/test/util/net.cppsrc/test/fuzz/process_message.cppsrc/test/fuzz/process_messages.cppInspect captured patch +10 / −4
diff --git a/src/test/fuzz/process_message.cpp b/src/test/fuzz/process_message.cpp
index 7a24c1de..3938735f 100644
--- a/src/test/fuzz/process_message.cpp
+++ b/src/test/fuzz/process_message.cpp
@@ -72,8 +72,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
auto& node{g_setup->m_node};
auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)};
- connman.ResetAddrCache();
- connman.ResetMaxOutboundCycle();
+ connman.Reset();
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
SetMockTime(1610000000); // any time to successfully reset ibd
diff --git a/src/test/fuzz/process_messages.cpp b/src/test/fuzz/process_messages.cpp
index 28bee67d..7b776fcc 100644
--- a/src/test/fuzz/process_messages.cpp
+++ b/src/test/fuzz/process_messages.cpp
@@ -62,8 +62,7 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
auto& node{g_setup->m_node};
auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)};
- connman.ResetAddrCache();
- connman.ResetMaxOutboundCycle();
+ connman.Reset();
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
SetMockTime(1610000000); // any time to successfully reset ibd
diff --git a/src/test/util/net.cpp b/src/test/util/net.cpp
index 0f59e0d6..160ef979 100644
--- a/src/test/util/net.cpp
+++ b/src/test/util/net.cpp
@@ -80,6 +80,12 @@ void ConnmanTestMsg::ResetMaxOutboundCycle()
nMaxOutboundTotalBytesSentInCycle = 0;
}
+void ConnmanTestMsg::Reset()
+{
+ ResetAddrCache();
+ ResetMaxOutboundCycle();
+}
+
void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, std::span<const uint8_t> msg_bytes, bool& complete) const
{
assert(node.ReceiveMsgBytes(msg_bytes, complete));
diff --git a/src/test/util/net.h b/src/test/util/net.h
index ee02d404..5d78eaf2 100644
--- a/src/test/util/net.h
+++ b/src/test/util/net.h
@@ -49,6 +49,8 @@ struct ConnmanTestMsg : public CConnman {
void ResetAddrCache();
void ResetMaxOutboundCycle();
+ /// Reset the internal state.
+ void Reset();
std::vector<CNode*> TestNodes()
{
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.