mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
The existing code provides two randomness mechanisms for test purposes: - g_insecure_rand_ctx (with its wrappers InsecureRand*), which during tests is initialized using either zeros (SeedRand::ZEROS), or using environment-provided randomness (SeedRand::SEED). - g_mock_deterministic_tests, which controls some (but not all) of the normal randomness output if set, but then makes it extremely predictable (identical output repeatedly). Replace this with a single mechanism, which retains the SeedRand modes to control all randomness. There is a new internal deterministic PRNG inside the random module, which is used in GetRandBytes() when in test mode, and which is also used to initialize g_insecure_rand_ctx. This means that during tests, all random numbers are made deterministic. There is one exception, GetStrongRandBytes(), which even in test mode still uses the normal PRNG state. This probably opens the door to removing a lot of the ad-hoc "deterministic" mode functions littered through the codebase (by simply running relevant tests in SeedRand::ZEROS mode), but this isn't done yet. |
||
|---|---|---|
| .. | ||
| blockfilter.cpp | ||
| blockfilter.h | ||
| chainstate.h | ||
| coins.cpp | ||
| coins.h | ||
| index.cpp | ||
| index.h | ||
| json.cpp | ||
| json.h | ||
| logging.cpp | ||
| logging.h | ||
| mining.cpp | ||
| mining.h | ||
| net.cpp | ||
| net.h | ||
| poolresourcetester.h | ||
| random.cpp | ||
| random.h | ||
| README.md | ||
| script.cpp | ||
| script.h | ||
| setup_common.cpp | ||
| setup_common.h | ||
| str.cpp | ||
| str.h | ||
| transaction_utils.cpp | ||
| transaction_utils.h | ||
| txmempool.cpp | ||
| txmempool.h | ||
| validation.cpp | ||
| validation.h | ||
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).