4
4
5
5
#include " wallet/wallet.h"
6
6
#include " wallet/coinselection.h"
7
+ #include " wallet/coincontrol.h"
7
8
#include " amount.h"
8
9
#include " primitives/transaction.h"
9
10
#include " random.h"
@@ -27,7 +28,7 @@ std::vector<std::unique_ptr<CWalletTx>> wtxn;
27
28
typedef std::set<CInputCoin> CoinSet;
28
29
29
30
static std::vector<COutput> vCoins;
30
- static const CWallet testWallet (" dummy" , CWalletDBWrapper::CreateDummy());
31
+ static CWallet testWallet (" dummy" , CWalletDBWrapper::CreateDummy());
31
32
static CAmount balance = 0 ;
32
33
33
34
CoinEligibilityFilter filter_standard (1 , 6 , 0 );
@@ -72,6 +73,7 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa
72
73
}
73
74
COutput output (wtx.get (), nInput, nAge, true /* spendable */ , true /* solvable */ , true /* safe */ );
74
75
vCoins.push_back (output);
76
+ testWallet.AddToWallet (*wtx.get ());
75
77
wtxn.emplace_back (std::move (wtx));
76
78
}
77
79
@@ -222,6 +224,18 @@ BOOST_AUTO_TEST_CASE(bnb_search_test)
222
224
add_coin (1 );
223
225
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
226
BOOST_CHECK (!testWallet.SelectCoinsMinConf ( 1 * CENT, filter_standard, vCoins, setCoinsRet, nValueRet, coin_selection_params_bnb, bnb_used));
227
+
228
+ // Make sure that we aren't using BnB when there are preset inputs
229
+ empty_wallet ();
230
+ add_coin (5 * CENT);
231
+ add_coin (3 * CENT);
232
+ add_coin (2 * CENT);
233
+ CCoinControl coin_control;
234
+ coin_control.fAllowOtherInputs = true ;
235
+ coin_control.Select (COutPoint (vCoins.at (0 ).tx ->GetHash (), vCoins.at (0 ).i ));
236
+ BOOST_CHECK (testWallet.SelectCoins (vCoins, 10 * CENT, setCoinsRet, nValueRet, coin_control, coin_selection_params_bnb, bnb_used));
237
+ BOOST_CHECK (!bnb_used);
238
+ BOOST_CHECK (!coin_selection_params_bnb.use_bnb );
225
239
}
226
240
227
241
BOOST_AUTO_TEST_CASE (knapsack_solver_test)
0 commit comments