Skip to content

Commit aeeeeec

Browse files
author
MarcoFalke
committed
fuzz: Reset dirty connman state in process_message(s) targets
1 parent fa11eea commit aeeeeec

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/test/fuzz/process_message.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
6060
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
6161

6262
auto& connman = static_cast<ConnmanTestMsg&>(*g_setup->m_node.connman);
63+
connman.ResetAddrCache();
64+
connman.ResetMaxOutboundCycle();
6365
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
6466
SetMockTime(1610000000); // any time to successfully reset ibd
6567
chainman.ResetIbd();

src/test/fuzz/process_messages.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
5050
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
5151

5252
auto& connman = static_cast<ConnmanTestMsg&>(*g_setup->m_node.connman);
53+
connman.ResetAddrCache();
54+
connman.ResetMaxOutboundCycle();
5355
auto& chainman = static_cast<TestChainstateManager&>(*g_setup->m_node.chainman);
5456
SetMockTime(1610000000); // any time to successfully reset ibd
5557
chainman.ResetIbd();

src/test/util/net.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ void ConnmanTestMsg::Handshake(CNode& node,
7171
}
7272
}
7373

74+
void ConnmanTestMsg::ResetAddrCache() { m_addr_response_caches = {}; }
75+
76+
void ConnmanTestMsg::ResetMaxOutboundCycle()
77+
{
78+
LOCK(m_total_bytes_sent_mutex);
79+
nMaxOutboundCycleStartTime = 0s;
80+
nMaxOutboundTotalBytesSentInCycle = 0;
81+
}
82+
7483
void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, std::span<const uint8_t> msg_bytes, bool& complete) const
7584
{
7685
assert(node.ReceiveMsgBytes(msg_bytes, complete));

src/test/util/net.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct ConnmanTestMsg : public CConnman {
4545
m_peer_connect_timeout = timeout;
4646
}
4747

48+
void ResetAddrCache();
49+
void ResetMaxOutboundCycle();
50+
4851
std::vector<CNode*> TestNodes()
4952
{
5053
LOCK(m_nodes_mutex);

0 commit comments

Comments
 (0)