mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
fuzz: coinselection, add coverage for GetShuffledInputVector
/GetInputSet
This commit is contained in:
parent
808618b8a2
commit
f0244a8614
1 changed files with 11 additions and 1 deletions
|
@ -100,16 +100,26 @@ FUZZ_TARGET(coinselection)
|
|||
|
||||
// Run coinselection algorithms
|
||||
auto result_bnb = SelectCoinsBnB(group_pos, target, cost_of_change, MAX_STANDARD_TX_WEIGHT);
|
||||
if (result_bnb) {
|
||||
(void)result_bnb->GetShuffledInputVector();
|
||||
(void)result_bnb->GetInputSet();
|
||||
}
|
||||
|
||||
auto result_srd = SelectCoinsSRD(group_pos, target, coin_params.m_change_fee, fast_random_context, MAX_STANDARD_TX_WEIGHT);
|
||||
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);
|
||||
(void)result_srd->GetShuffledInputVector();
|
||||
(void)result_srd->GetInputSet();
|
||||
}
|
||||
|
||||
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);
|
||||
if (result_knapsack) result_knapsack->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
|
||||
if (result_knapsack) {
|
||||
result_knapsack->ComputeAndSetWaste(cost_of_change, cost_of_change, 0);
|
||||
(void)result_knapsack->GetShuffledInputVector();
|
||||
(void)result_knapsack->GetInputSet();
|
||||
}
|
||||
|
||||
// If the total balance is sufficient for the target and we are not using
|
||||
// effective values, Knapsack should always find a solution (unless the selection exceeded the max tx weight).
|
||||
|
|
Loading…
Add table
Reference in a new issue