diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-01-21 16:02:02 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-01-21 16:04:31 +0100 |
commit | 85fee49c39cc77b07ba57e0e7cc97f1a5b7e230c (patch) | |
tree | 3be6ed3a0bb619909257bd02831138f806fb6aa4 /src/test/fuzz/process_message.cpp | |
parent | 3734adba390cef881445c4de780e2a3bb080c512 (diff) | |
parent | abb6fa728598c4cc8874eae1c3c5e587e36424cd (diff) | |
download | bitcoin-85fee49c39cc77b07ba57e0e7cc97f1a5b7e230c.tar.xz |
Merge #20946: fuzz: Consolidate fuzzing TestingSetup initialization
abb6fa728598c4cc8874eae1c3c5e587e36424cd fuzz: Initialize a full TestingSetup where appropriate (Carl Dong)
713314abfa224efceb7ba6fa7fef37c449902936 fuzz: Consolidate fuzzing TestingSetup initialization (Carl Dong)
Pull request description:
```
Previously, the {Basic,}TestingSetup for fuzzers were set up in many ways:
1. Calling InitializeFuzzingContext, which implicitly constructs a static
const BasicTestingSetup
2. Directly constructing a static const BasicTestingSetup in the initialize_*
function
3. Directly constructing a static TestingSetup and reproducing the
initialization arguments (I'm assuming because
InitializeFuzzingContext only initializes a BasicTestingSetup)
The new, relatively-simple MakeFuzzingContext function allows us to
consolidate these methods of initialization by being flexible enough to
be used in all situations. It:
1. Is templated so that we can choose to initialize any of
the *TestingSetup classes
2. Has sane defaults which are often used in fuzzers but are also
easily overridable
3. Returns a unique_ptr, explicitly transferring ownership to the caller
to deal with according to its situation
```
~~Question for fuzzing people: was it intentional that `src/test/fuzz/net.cpp` would directly instantiate the `BasicTestingSetup` and thus omit the `"-nodebuglogfile"` flag?~~ [Answered](https://github.com/bitcoin/bitcoin/pull/20946#issuecomment-761537108)
ACKs for top commit:
MarcoFalke:
ACK abb6fa728598c4cc8874eae1c3c5e587e36424cd
Tree-SHA512: 96a5ca6f4cd5ea0e9483b60165b31ae3e9003918c700a7f6ade48010f419f2a6312e10b816b3187f1d263798827571866e4c4ac0bbfb2e0c79dfad254cda68e7
Diffstat (limited to 'src/test/fuzz/process_message.cpp')
-rw-r--r-- | src/test/fuzz/process_message.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/test/fuzz/process_message.cpp b/src/test/fuzz/process_message.cpp index e9aeef1d32..5d6a33d7c2 100644 --- a/src/test/fuzz/process_message.cpp +++ b/src/test/fuzz/process_message.cpp @@ -38,14 +38,8 @@ const TestingSetup* g_setup; void initialize_process_message() { - static TestingSetup setup{ - CBaseChainParams::REGTEST, - { - "-nodebuglogfile", - }, - }; - g_setup = &setup; - + static const auto testing_setup = MakeFuzzingContext<const TestingSetup>(); + g_setup = testing_setup.get(); for (int i = 0; i < 2 * COINBASE_MATURITY; i++) { MineBlock(g_setup->m_node, CScript() << OP_TRUE); } |