Skip to content

Commit f0244a8

Browse files
committed
fuzz: coinselection, add coverage for GetShuffledInputVector/GetInputSet
1 parent 808618b commit f0244a8

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/wallet/test/fuzz/coinselection.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,26 @@ FUZZ_TARGET(coinselection)
100100

101101
// Run coinselection algorithms
102102
auto result_bnb = SelectCoinsBnB(group_pos, target, cost_of_change, MAX_STANDARD_TX_WEIGHT);
103+
if (result_bnb) {
104+
(void)result_bnb->GetShuffledInputVector();
105+
(void)result_bnb->GetInputSet();
106+
}
103107

104108
auto result_srd = SelectCoinsSRD(group_pos, target, coin_params.m_change_fee, fast_random_context, MAX_STANDARD_TX_WEIGHT);
105109
if (result_srd) {
106110
assert(result_srd->GetChange(CHANGE_LOWER, coin_params.m_change_fee) > 0); // Demonstrate that SRD creates change of at least CHANGE_LOWER
107111
result_srd->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
112+
(void)result_srd->GetShuffledInputVector();
113+
(void)result_srd->GetInputSet();
108114
}
109115

110116
CAmount change_target{GenerateChangeTarget(target, coin_params.m_change_fee, fast_random_context)};
111117
auto result_knapsack = KnapsackSolver(group_all, target, change_target, fast_random_context, MAX_STANDARD_TX_WEIGHT);
112-
if (result_knapsack) result_knapsack->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
118+
if (result_knapsack) {
119+
result_knapsack->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
120+
(void)result_knapsack->GetShuffledInputVector();
121+
(void)result_knapsack->GetInputSet();
122+
}
113123

114124
// If the total balance is sufficient for the target and we are not using
115125
// effective values, Knapsack should always find a solution (unless the selection exceeded the max tx weight).

0 commit comments

Comments
 (0)