bitcoin/src/test/util
MarcoFalke f63fc53c2a
Merge bitcoin/bitcoin#21767: [Bundle 6/n] Prune g_chainman usage in auxiliary modules
7a799c9c2b index: refactor-only: Reuse CChain ref (Carl Dong)
db33cde80f index: Add chainstate member to BaseIndex (Carl Dong)
f4a47a1feb bench: Use existing chainman in AssembleBlock (Carl Dong)
91226eb917 bench: Use existing NodeContext in DuplicateInputs (Carl Dong)
e6b4aa6eb5 miner: Pass in chainman to RegenerateCommitments (Carl Dong)
9ecade1425 rest: Add GetChainman function and use it (Carl Dong)
fc1c282845 rpc/blockchain: Use existing blockman in gettxoutsetinfo (Carl Dong)

Pull request description:

  Overall PR: #20158 (tree-wide: De-globalize ChainstateManager)

  The first 2 commits are fixups addressing review for the last bundle: #21391

  NEW note:
  1. I have opened #21766 which keeps track of potential improvements where the flaws already existed before the de-globalization work, please post on that issue about these improvements, thanks!

  Note to reviewers:
  1. This bundle may _apparently_ introduce usage of `g_chainman` or `::Chain(state|)Active()` globals, but these are resolved later on in the overall PR. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits)
  2. There may be seemingly obvious local references to `ChainstateManager` or other validation objects which are not being used in callers of the current function in question, this is done intentionally to **_keep each commit centered around one function/method_** to ease review and to make the overall change systematic. We don't assume anything about our callers. Rest assured that once we are considering that particular caller in later commits, we will use the obvious local references. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits)
  3. When changing a function/method that has many callers (e.g. `LookupBlockIndex` with 55 callers), it is sometimes easier (and less error-prone) to use a scripted-diff. When doing so, there will be 3 commits in sequence so that every commit compiles like so:
  1. Add `new_function`, make `old_function` a wrapper of `new_function`, divert all calls to `old_function` to `new_function` **in the local module only**
  2. Scripted-diff to divert all calls to `old_function` to `new_function` **in the rest of the codebase**
  3. Remove `old_function`

ACKs for top commit:
  jarolrod:
    ACK  7a799c9
  ariard:
    Code Review ACK 7a799c9
  fjahr:
    re-ACK 7a799c9c2b
  MarcoFalke:
    review ACK 7a799c9c2b 🌠
  ryanofsky:
    Code review ACK 7a799c9c2b. Basically no change since last review except fixed rebase conflicts and a new comment about REST Ensure()
  jamesob:
    conditional ACK 7a799c9c2b ([`jamesob/ackr/21767.1.dongcarl.bundle_6_n_prune_g_chai`](https://github.com/jamesob/bitcoin/tree/ackr/21767.1.dongcarl.bundle_6_n_prune_g_chai))

Tree-SHA512: 531c00ddcb318817457db2812d9a9d930bc664e58e6f7f1c746350732b031dd624270bfa6b9f49d8056aeb6321d973f0e38e4ff914acd6768edd8602c017d10e
2021-06-01 13:34:18 +02:00
..
blockfilter.cpp move-only: Move *Disk functions to blockstorage 2021-04-05 20:26:14 +02:00
blockfilter.h scripted-diff: test: Move setup_common to test library 2019-11-06 11:56:41 -05:00
logging.cpp scripted-diff: remove MakeUnique<T>() 2021-03-11 13:45:14 +08:00
logging.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
mining.cpp fuzz: Add utxo_snapshot target 2021-05-16 11:34:27 +02:00
mining.h fuzz: Add utxo_snapshot target 2021-05-16 11:34:27 +02:00
net.cpp net: Treat raw message bytes as uint8_t 2020-11-20 15:11:21 +01:00
net.h scripted-diff: rename NetPermissionFlags enumerators 2021-05-12 16:13:30 +02:00
README.md doc: Add documentation for new test/lib 2019-11-06 11:56:53 -05:00
script.cpp fuzz: [refactor] Use IsValidFlagCombination in signature_checker fuzz target 2021-03-30 10:42:45 +02:00
script.h fuzz: [refactor] Use IsValidFlagCombination in signature_checker fuzz target 2021-03-30 10:42:45 +02:00
setup_common.cpp Merge bitcoin/bitcoin#21767: [Bundle 6/n] Prune g_chainman usage in auxiliary modules 2021-06-01 13:34:18 +02:00
setup_common.h [test] make submit optional in CreateValidMempoolTransaction 2021-05-24 14:42:10 +01:00
str.cpp tests: Move CaseInsensitiveEqual to test/util/str 2019-11-05 09:23:44 +00:00
str.h [test] move string helper functions into test library 2019-11-25 01:33:17 +01:00
transaction_utils.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
transaction_utils.h scripted-diff: TxoutType C++11 scoped enum class 2020-06-21 06:41:55 -04:00
validation.cpp test: Mock IBD in net_processing fuzzers 2020-11-07 07:50:59 +01:00
validation.h test: Mock IBD in net_processing fuzzers 2020-11-07 07:50:59 +01:00
wallet.cpp Locking: Lock cs_KeyStore instead of cs_wallet in legacy keyman 2020-01-23 16:34:28 -05:00
wallet.h [test] move wallet helper functions into test library 2019-11-25 16:40:09 +01:00

Test library

This contains files for the test library, which is used by the test binaries (unit tests, benchmarks, fuzzers, gui tests).

Generally, the files in this folder should be well-separated modules. New code should be added to existing modules or (when in doubt) a new module should be created.

The utilities in here are compiled into a library, which does not hold any state. However, the main file setup_common defines the common test setup for all test binaries. The test binaries will handle the global state when they instantiate the BasicTestingSetup (or one of its derived classes).