diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-12-06 12:03:56 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-12-06 13:11:38 +0100 |
commit | fae1e7e012571201fd51c547ba4fb6044be9aeb5 (patch) | |
tree | d190020bdfd518b29b3ec1b4ab4d3608b3e9f449 /src | |
parent | 6d5790956f45e3de5c6c4ee6fda21878b0d1287b (diff) |
fuzz: p2p: Detect peer deadlocks
Diffstat (limited to 'src')
-rw-r--r-- | src/test/fuzz/process_messages.cpp | 14 | ||||
-rw-r--r-- | src/test/util/net.h | 5 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/test/fuzz/process_messages.cpp b/src/test/fuzz/process_messages.cpp index b7e2e04b4b..3f722f60ee 100644 --- a/src/test/fuzz/process_messages.cpp +++ b/src/test/fuzz/process_messages.cpp @@ -78,13 +78,17 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages) connman.FlushSendBuffer(random_node); (void)connman.ReceiveMsgFrom(random_node, std::move(net_msg)); - random_node.fPauseSend = false; - try { - connman.ProcessMessagesOnce(random_node); - } catch (const std::ios_base::failure&) { + bool more_work{true}; + while (more_work) { // Ensure that every message is eventually processed in some way or another + random_node.fPauseSend = false; + + try { + more_work = connman.ProcessMessagesOnce(random_node); + } catch (const std::ios_base::failure&) { + } + g_setup->m_node.peerman->SendMessages(&random_node); } - g_setup->m_node.peerman->SendMessages(&random_node); } SyncWithValidationInterfaceQueue(); g_setup->m_node.connman->StopNodes(); diff --git a/src/test/util/net.h b/src/test/util/net.h index 59c4ddb4b1..d91d801132 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -70,7 +70,10 @@ struct ConnmanTestMsg : public CConnman { bool relay_txs) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex); - void ProcessMessagesOnce(CNode& node) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex) { m_msgproc->ProcessMessages(&node, flagInterruptMsgProc); } + bool ProcessMessagesOnce(CNode& node) EXCLUSIVE_LOCKS_REQUIRED(NetEventsInterface::g_msgproc_mutex) + { + return m_msgproc->ProcessMessages(&node, flagInterruptMsgProc); + } void NodeReceiveMsgBytes(CNode& node, Span<const uint8_t> msg_bytes, bool& complete) const; |