fuzz: Use mocktime in process_message* fuzz targets

This commit is contained in:
MarcoFalke
2021-01-10 16:41:52 +01:00
parent 6af013792f
commit fa0a864b38
2 changed files with 11 additions and 6 deletions

View File

@@ -41,10 +41,10 @@ FUZZ_TARGET_INIT(process_messages, initialize_process_messages)
ConnmanTestMsg& connman = *(ConnmanTestMsg*)g_setup->m_node.connman.get();
TestChainState& chainstate = *(TestChainState*)&g_setup->m_node.chainman->ActiveChainstate();
SetMockTime(1610000000); // any time to successfully reset ibd
chainstate.ResetIbd();
std::vector<CNode*> peers;
bool jump_out_of_ibd{false};
std::vector<CNode*> peers;
const auto num_peers_to_add = fuzzed_data_provider.ConsumeIntegralInRange(1, 3);
for (int i = 0; i < num_peers_to_add; ++i) {
peers.push_back(ConsumeNodeAsUniquePtr(fuzzed_data_provider, i).release());
@@ -59,10 +59,11 @@ FUZZ_TARGET_INIT(process_messages, initialize_process_messages)
}
while (fuzzed_data_provider.ConsumeBool()) {
if (!jump_out_of_ibd) jump_out_of_ibd = fuzzed_data_provider.ConsumeBool();
if (jump_out_of_ibd && chainstate.IsInitialBlockDownload()) chainstate.JumpOutOfIbd();
const std::string random_message_type{fuzzed_data_provider.ConsumeBytesAsString(CMessageHeader::COMMAND_SIZE).c_str()};
const auto mock_time = ConsumeTime(fuzzed_data_provider);
SetMockTime(mock_time);
CSerializedNetMsg net_msg;
net_msg.m_type = random_message_type;
net_msg.data = ConsumeRandomLengthByteVector(fuzzed_data_provider);