mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Change SelectCoins_test to actually test SelectCoins
This was originally modified to use SelectCoinsMinConf in order to test both BnB and Knapsack at the same time. But since SelectCoins does both now, this is no longer necessary and we can revert back to actually testing SelectCoins.
This commit is contained in:
@@ -613,6 +613,7 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
|
||||
// Tests that with the ideal conditions, the coin selector will always be able to find a solution that can pay the target value
|
||||
BOOST_AUTO_TEST_CASE(SelectCoins_test)
|
||||
{
|
||||
LOCK(testWallet.cs_wallet);
|
||||
testWallet.SetupLegacyScriptPubKeyMan();
|
||||
|
||||
// Random generator stuff
|
||||
@@ -638,18 +639,14 @@ BOOST_AUTO_TEST_CASE(SelectCoins_test)
|
||||
CAmount target = rand.randrange(balance - 1000) + 1000;
|
||||
|
||||
// Perform selection
|
||||
CoinSelectionParams coin_selection_params_knapsack(/* change_output_size= */ 34,
|
||||
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
|
||||
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
|
||||
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
|
||||
CoinSelectionParams coin_selection_params_bnb(/* change_output_size= */ 34,
|
||||
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
|
||||
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
|
||||
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
|
||||
CoinSelectionParams cs_params(/* change_output_size= */ 34,
|
||||
/* change_spend_size= */ 148, /* effective_feerate= */ CFeeRate(0),
|
||||
/* long_term_feerate= */ CFeeRate(0), /* discard_feerate= */ CFeeRate(0),
|
||||
/* tx_no_inputs_size= */ 0, /* avoid_partial= */ false);
|
||||
CoinSet out_set;
|
||||
CAmount out_value = 0;
|
||||
BOOST_CHECK(testWallet.SelectCoinsMinConf(target, filter_standard, vCoins, out_set, out_value, coin_selection_params_bnb) ||
|
||||
testWallet.SelectCoinsMinConf(target, filter_standard, vCoins, out_set, out_value, coin_selection_params_knapsack));
|
||||
CCoinControl cc;
|
||||
BOOST_CHECK(testWallet.SelectCoins(vCoins, target, out_set, out_value, cc, cs_params));
|
||||
BOOST_CHECK_GE(out_value, target);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user