aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/process_messages.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-11-10 19:50:52 +0100
committerMarcoFalke <falke.marco@gmail.com>2020-11-10 19:51:11 +0100
commitfa8dd34e918cd80db215df8937aaf6bb1552fcd9 (patch)
treefc87a7dae12887880b668d3a7c14ceaae5ca2a90 /src/test/fuzz/process_messages.cpp
parent42f950cb27b732782d55282cdcd934396fcd7071 (diff)
parentfa4234d877ea3193bfd0e18ff68dcb8fb84b47b5 (diff)
Merge #20332: test: Mock IBD in net_processing fuzzers
fa4234d877ea3193bfd0e18ff68dcb8fb84b47b5 test: Mock IBD in net_processing fuzzers (MarcoFalke) Pull request description: Without this the fuzzers fail to detect trivial crasher bugs, such as https://github.com/bitcoin/bitcoin/pull/20317#issuecomment-723047111 ACKs for top commit: practicalswift: Tested ACK fa4234d877ea3193bfd0e18ff68dcb8fb84b47b5 Tree-SHA512: ce5da5c0a604b7559805a98ffdde882b44ca4f91b003b493d6e1be230714ce4cccb11dbfc1fc175f9d8fc779551c0a4103ceb4b473552928207d7d78ae329e10
Diffstat (limited to 'src/test/fuzz/process_messages.cpp')
-rw-r--r--src/test/fuzz/process_messages.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/test/fuzz/process_messages.cpp b/src/test/fuzz/process_messages.cpp
index f722eeac3a..19ea92b750 100644
--- a/src/test/fuzz/process_messages.cpp
+++ b/src/test/fuzz/process_messages.cpp
@@ -12,6 +12,7 @@
#include <test/util/mining.h>
#include <test/util/net.h>
#include <test/util/setup_common.h>
+#include <test/util/validation.h>
#include <util/memory.h>
#include <validation.h>
#include <validationinterface.h>
@@ -39,7 +40,10 @@ void test_one_input(const std::vector<uint8_t>& buffer)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
ConnmanTestMsg& connman = *(ConnmanTestMsg*)g_setup->m_node.connman.get();
+ TestChainState& chainstate = *(TestChainState*)&g_setup->m_node.chainman->ActiveChainstate();
+ chainstate.ResetIbd();
std::vector<CNode*> peers;
+ bool jump_out_of_ibd{false};
const auto num_peers_to_add = fuzzed_data_provider.ConsumeIntegralInRange(1, 3);
for (int i = 0; i < num_peers_to_add; ++i) {
@@ -58,6 +62,8 @@ void test_one_input(const std::vector<uint8_t>& buffer)
}
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()};
CSerializedNetMsg net_msg;