HomePhabricator

fuzz: Consolidate fuzzing TestingSetup initialization

Description

fuzz: Consolidate fuzzing TestingSetup initialization

Summary:
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

This is a backport of core#20946 [1/2]
https://github.com/bitcoin/bitcoin/pull/20946/commits/713314abfa224efceb7ba6fa7fef37c449902936

Note: this backport is a dependency for core#21866 (removal of global Chainstate)

Test Plan: ninja bitcoin-fuzzers

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11678

Details

Provenance
Carl Dong <contact@carldong.me>Authored on Jan 15 2021, 20:31
PiRKCommitted on Jun 29 2022, 08:32
PiRKPushed on Jun 29 2022, 08:32
Reviewer
Restricted Project
Differential Revision
D11678: fuzz: Consolidate fuzzing TestingSetup initialization
Parents
rABCda16f6a0d1bf: [Automated] Update timing.json
Branches
Unknown
Tags
Unknown