Skip to content

Commit 73b5bf2

Browse files
committed
Add a test to make sure that negative effective values are filtered
1 parent 76d2f06 commit 73b5bf2

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/wallet/test/coinselector_tests.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ static std::vector<COutput> vCoins;
3030
static const CWallet testWallet("dummy", CWalletDBWrapper::CreateDummy());
3131
static CAmount balance = 0;
3232

33+
CoinEligibilityFilter filter_standard(1, 6, 0);
34+
CoinEligibilityFilter filter_confirmed(1, 1, 0);
35+
CoinEligibilityFilter filter_standard_extra(6, 6, 0);
36+
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0);
37+
3338
static void add_coin(const CAmount& nValue, int nInput, std::vector<CInputCoin>& set)
3439
{
3540
CMutableTransaction tx;
@@ -207,12 +212,17 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
207212
for (int i = 0; i < 100; ++i) {
208213
BOOST_CHECK(!SelectCoinsBnB(utxo_pool, 1 * CENT, 2 * CENT, selection, value_ret, not_input_fees));
209214
}
210-
}
211215

212-
CoinEligibilityFilter filter_standard(1, 6, 0);
213-
CoinEligibilityFilter filter_confirmed(1, 1, 0);
214-
CoinEligibilityFilter filter_standard_extra(6, 6, 0);
215-
CoinSelectionParams coin_selection_params(false, 0, 0, CFeeRate(0), 0);
216+
// Make sure that effective value is working in SelectCoinsMinConf when BnB is used
217+
CoinSelectionParams coin_selection_params_bnb(true, 0, 0, CFeeRate(3000), 0);
218+
CoinSet setCoinsRet;
219+
CAmount nValueRet;
220+
bool bnb_used;
221+
empty_wallet();
222+
add_coin(1);
223+
vCoins.at(0).nInputBytes = 40; // Make sure that it has a negative effective value. The next check should assert if this somehow got through. Otherwise it will fail
224+
BOOST_CHECK(!testWallet.SelectCoinsMinConf( 1 * CENT, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params_bnb, bnb_used));
225+
}
216226

217227
BOOST_AUTO_TEST_CASE(knapsack_solver_test)
218228
{

0 commit comments

Comments
 (0)