test: add ConnmanTestMsg convenience method Reset()

This commit is contained in:
Vasil Dimov committed 2026-02-05 09:43:43 +01:00
1 parent 4ae00e9a71
commit 91b7c874e2
4 files changed
+10 -4

No files matched your search

+1 -2
View File
@@ -72,8 +72,7 @@ FUZZ_TARGET(process_message, .init = initialize_process_message)
auto& node{g_setup->m_node}; auto& node{g_setup->m_node};
auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)}; auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)};
connman.ResetAddrCache(); connman.Reset();
connman.ResetMaxOutboundCycle();
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)}; auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())}; const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
SetMockTime(1610000000); // any time to successfully reset ibd SetMockTime(1610000000); // any time to successfully reset ibd
+1 -2
View File
@@ -62,8 +62,7 @@ FUZZ_TARGET(process_messages, .init = initialize_process_messages)
auto& node{g_setup->m_node}; auto& node{g_setup->m_node};
auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)}; auto& connman{static_cast<ConnmanTestMsg&>(*node.connman)};
connman.ResetAddrCache(); connman.Reset();
connman.ResetMaxOutboundCycle();
auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)}; auto& chainman{static_cast<TestChainstateManager&>(*node.chainman)};
const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())}; const auto block_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
SetMockTime(1610000000); // any time to successfully reset ibd SetMockTime(1610000000); // any time to successfully reset ibd
+6
View File
@@ -80,6 +80,12 @@ void ConnmanTestMsg::ResetMaxOutboundCycle()
nMaxOutboundTotalBytesSentInCycle = 0; nMaxOutboundTotalBytesSentInCycle = 0;
} }
void ConnmanTestMsg::Reset()
{
ResetAddrCache();
ResetMaxOutboundCycle();
}
void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, std::span<const uint8_t> msg_bytes, bool& complete) const void ConnmanTestMsg::NodeReceiveMsgBytes(CNode& node, std::span<const uint8_t> msg_bytes, bool& complete) const
{ {
assert(node.ReceiveMsgBytes(msg_bytes, complete)); assert(node.ReceiveMsgBytes(msg_bytes, complete));
+2
View File
@@ -49,6 +49,8 @@ struct ConnmanTestMsg : public CConnman {
void ResetAddrCache(); void ResetAddrCache();
void ResetMaxOutboundCycle(); void ResetMaxOutboundCycle();
/// Reset the internal state.
void Reset();
std::vector<CNode*> TestNodes() std::vector<CNode*> TestNodes()
{ {