|
14 | 14 | #include <test/fuzz/FuzzedDataProvider.h>
|
15 | 15 | #include <test/fuzz/fuzz.h>
|
16 | 16 | #include <test/util/mining.h>
|
| 17 | +#include <test/util/net.h> |
17 | 18 | #include <test/util/setup_common.h>
|
18 | 19 | #include <util/memory.h>
|
19 | 20 | #include <validationinterface.h>
|
@@ -63,19 +64,23 @@ void initialize()
|
63 | 64 | void test_one_input(const std::vector<uint8_t>& buffer)
|
64 | 65 | {
|
65 | 66 | FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
|
| 67 | + ConnmanTestMsg& connman = *(ConnmanTestMsg*)g_setup->m_node.connman.get(); |
66 | 68 | const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
|
67 | 69 | if (!LIMIT_TO_MESSAGE_TYPE.empty() && random_message_type != LIMIT_TO_MESSAGE_TYPE) {
|
68 | 70 | return;
|
69 | 71 | }
|
70 | 72 | CDataStream random_bytes_data_stream{fuzzed_data_provider.ConsumeRemainingBytes<unsigned char>(), SER_NETWORK, PROTOCOL_VERSION};
|
71 |
| - CNode p2p_node{0, ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BLOOM), 0, INVALID_SOCKET, CAddress{CService{in_addr{0x0100007f}, 7777}, NODE_NETWORK}, 0, 0, CAddress{}, std::string{}, false}; |
| 73 | + CNode& p2p_node = *MakeUnique<CNode>(0, ServiceFlags(NODE_NETWORK | NODE_WITNESS | NODE_BLOOM), 0, INVALID_SOCKET, CAddress{CService{in_addr{0x0100007f}, 7777}, NODE_NETWORK}, 0, 0, CAddress{}, std::string{}, false).release(); |
72 | 74 | p2p_node.fSuccessfullyConnected = true;
|
73 | 75 | p2p_node.nVersion = PROTOCOL_VERSION;
|
74 | 76 | p2p_node.SetSendVersion(PROTOCOL_VERSION);
|
| 77 | + connman.AddTestNode(p2p_node); |
75 | 78 | g_setup->m_node.peer_logic->InitializeNode(&p2p_node);
|
76 | 79 | try {
|
77 | 80 | (void)ProcessMessage(&p2p_node, random_message_type, random_bytes_data_stream, GetTimeMillis(), Params(), *g_setup->m_node.chainman, *g_setup->m_node.mempool, g_setup->m_node.connman.get(), g_setup->m_node.banman.get(), std::atomic<bool>{false});
|
78 | 81 | } catch (const std::ios_base::failure&) {
|
79 | 82 | }
|
80 | 83 | SyncWithValidationInterfaceQueue();
|
| 84 | + LOCK2(::cs_main, g_cs_orphans); // See init.cpp for rationale for implicit locking order requirement |
| 85 | + g_setup->m_node.connman->StopNodes(); |
81 | 86 | }
|
0 commit comments