diff options
author | Greg Sanders <gsanders87@gmail.com> | 2023-11-08 12:09:15 -0500 |
---|---|---|
committer | Greg Sanders <gsanders87@gmail.com> | 2023-11-09 09:07:03 -0500 |
commit | 6a917918b76eef154c6757fe9ecf7713d526c3dd (patch) | |
tree | c6846ac9a79ddb54636598b68d9332c41505ab72 /src/test | |
parent | a0626ccdadc0e965dc818d8a7c862e8c81b54fd1 (diff) | |
download | bitcoin-6a917918b76eef154c6757fe9ecf7713d526c3dd.tar.xz |
fuzz: allow fake and duplicate inputs in tx_package_eval target
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/fuzz/package_eval.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/test/fuzz/package_eval.cpp b/src/test/fuzz/package_eval.cpp index 6dd9ef2c63..8658c0b45a 100644 --- a/src/test/fuzz/package_eval.cpp +++ b/src/test/fuzz/package_eval.cpp @@ -205,6 +205,18 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool) tx_mut.vin.push_back(in); } + + // Duplicate an input + bool dup_input = fuzzed_data_provider.ConsumeBool(); + if (dup_input) { + tx_mut.vin.push_back(tx_mut.vin.back()); + } + + // Refer to a non-existant input + if (fuzzed_data_provider.ConsumeBool()) { + tx_mut.vin.emplace_back(); + } + const auto amount_fee = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, amount_in); const auto amount_out = (amount_in - amount_fee) / num_out; for (int i = 0; i < num_out; ++i) { @@ -215,7 +227,8 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool) // Restore previously removed outpoints, except in-package outpoints if (!last_tx) { for (const auto& in : tx->vin) { - Assert(outpoints.insert(in.prevout).second); + // It's a fake input, or a new input, or a duplicate + Assert(in == CTxIn() || outpoints.insert(in.prevout).second || dup_input); } // Cache the in-package outpoints being made for (size_t i = 0; i < tx->vout.size(); ++i) { |