Skip to content

Commit 1771daa

Browse files
committed
[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.
1 parent 941b8c6 commit 1771daa

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/wallet/test/fuzz/coinselection.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ FUZZ_TARGET(coinselection)
9191
const auto result_bnb = SelectCoinsBnB(group_pos, target, cost_of_change, MAX_STANDARD_TX_WEIGHT);
9292

9393
auto result_srd = SelectCoinsSRD(group_pos, target, coin_params.m_change_fee, fast_random_context, MAX_STANDARD_TX_WEIGHT);
94-
if (result_srd) result_srd->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
94+
if (result_srd) {
95+
assert(result_srd->GetChange(CHANGE_LOWER, coin_params.m_change_fee) > 0); // Demonstrate that SRD creates change of at least CHANGE_LOWER
96+
result_srd->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
97+
}
9598

9699
CAmount change_target{GenerateChangeTarget(target, coin_params.m_change_fee, fast_random_context)};
97100
auto result_knapsack = KnapsackSolver(group_all, target, change_target, fast_random_context, MAX_STANDARD_TX_WEIGHT);

0 commit comments

Comments
 (0)