diff options
-rw-r--r-- | src/wallet/test/fuzz/coinselection.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/wallet/test/fuzz/coinselection.cpp b/src/wallet/test/fuzz/coinselection.cpp index 6545d9ad9e..1a682599fe 100644 --- a/src/wallet/test/fuzz/coinselection.cpp +++ b/src/wallet/test/fuzz/coinselection.cpp @@ -99,7 +99,7 @@ FUZZ_TARGET(coinselection) } // Run coinselection algorithms - const auto result_bnb = SelectCoinsBnB(group_pos, target, cost_of_change, MAX_STANDARD_TX_WEIGHT); + auto result_bnb = SelectCoinsBnB(group_pos, target, cost_of_change, MAX_STANDARD_TX_WEIGHT); auto result_srd = SelectCoinsSRD(group_pos, target, coin_params.m_change_fee, fast_random_context, MAX_STANDARD_TX_WEIGHT); if (result_srd) { @@ -116,6 +116,22 @@ FUZZ_TARGET(coinselection) if (total_balance >= target && subtract_fee_outputs && !HasErrorMsg(result_knapsack)) { assert(result_knapsack); } + + std::vector<COutput> utxos; + std::vector<util::Result<SelectionResult>> results{result_srd, result_knapsack, result_bnb}; + CAmount new_total_balance{CreateCoins(fuzzed_data_provider, utxos, coin_params, next_locktime)}; + if (new_total_balance > 0) { + std::set<std::shared_ptr<COutput>> new_utxo_pool; + for (const auto& utxo : utxos) { + new_utxo_pool.insert(std::make_shared<COutput>(utxo)); + } + for (auto& result : results) { + if (!result) continue; + const auto weight{result->GetWeight()}; + result->AddInputs(new_utxo_pool, subtract_fee_outputs); + assert(result->GetWeight() > weight); + } + } } } // namespace wallet |