mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 06:43:45 +01:00
Add FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in PoW check
To avoid PoW being a blocker for fuzz tests, `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is used in fuzz builds to bypass the actual PoW validation in `CheckProofOfWork`. It's replaced with a check on the last byte of the hash, which allows the fuzzer to quickly generate (in)valid blocks by checking a single bit, rather than performing the full PoW computation. If PoW is the target of a fuzz test, then it should call `CheckProofOfWorkImpl`.
This commit is contained in:
@@ -69,7 +69,7 @@ FUZZ_TARGET(integer, .init = initialize_integer)
|
||||
const bool b = fuzzed_data_provider.ConsumeBool();
|
||||
|
||||
const Consensus::Params& consensus_params = Params().GetConsensus();
|
||||
(void)CheckProofOfWork(u256, u32, consensus_params);
|
||||
(void)CheckProofOfWorkImpl(u256, u32, consensus_params);
|
||||
if (u64 <= MAX_MONEY) {
|
||||
const uint64_t compressed_money_amount = CompressAmount(u64);
|
||||
assert(u64 == DecompressAmount(compressed_money_amount));
|
||||
|
||||
Reference in New Issue
Block a user