[fuzz] Show that SRD budgets for non-dust change

Adding this assert to the fuzz test without increasing the change target
by the change_fee resulted in a crash within a few seconds.
This commit is contained in:
Murch 2023-06-14 16:52:08 -04:00
parent 941b8c6539
commit 1771daa815
No known key found for this signature in database
GPG Key ID: 7BA035CA5B901713

View File

@ -91,7 +91,10 @@ FUZZ_TARGET(coinselection)
const 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) result_srd->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
if (result_srd) {
assert(result_srd->GetChange(CHANGE_LOWER, coin_params.m_change_fee) > 0); // Demonstrate that SRD creates change of at least CHANGE_LOWER
result_srd->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
}
CAmount change_target{GenerateChangeTarget(target, coin_params.m_change_fee, fast_random_context)};
auto result_knapsack = KnapsackSolver(group_all, target, change_target, fast_random_context, MAX_STANDARD_TX_WEIGHT);