mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
fuzz: allow fake and duplicate inputs in tx_package_eval target
This commit is contained in:
parent
a0626ccdad
commit
6a917918b7
1 changed files with 14 additions and 1 deletions
|
@ -205,6 +205,18 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
||||||
|
|
||||||
tx_mut.vin.push_back(in);
|
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_fee = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(0, amount_in);
|
||||||
const auto amount_out = (amount_in - amount_fee) / num_out;
|
const auto amount_out = (amount_in - amount_fee) / num_out;
|
||||||
for (int i = 0; i < num_out; ++i) {
|
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
|
// Restore previously removed outpoints, except in-package outpoints
|
||||||
if (!last_tx) {
|
if (!last_tx) {
|
||||||
for (const auto& in : tx->vin) {
|
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
|
// Cache the in-package outpoints being made
|
||||||
for (size_t i = 0; i < tx->vout.size(); ++i) {
|
for (size_t i = 0; i < tx->vout.size(); ++i) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue