Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/coinselector_tests.cpp
Show First 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(bnb_search_test) { | ||||
BOOST_CHECK(m_wallet.SelectCoins(vCoins, 10 * CENT, setCoinsRet, nValueRet, | BOOST_CHECK(m_wallet.SelectCoins(vCoins, 10 * CENT, setCoinsRet, nValueRet, | ||||
coin_control, coin_selection_params_bnb, | coin_control, coin_selection_params_bnb, | ||||
bnb_used)); | bnb_used)); | ||||
BOOST_CHECK(!bnb_used); | BOOST_CHECK(!bnb_used); | ||||
BOOST_CHECK(!coin_selection_params_bnb.use_bnb); | BOOST_CHECK(!coin_selection_params_bnb.use_bnb); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(knapsack_solver_test) { | BOOST_AUTO_TEST_CASE(knapsack_solver_test) { | ||||
CWallet testWallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | CWallet testWallet(Params(), "dummy", WalletDatabase::CreateDummy()); | ||||
CoinSet setCoinsRet, setCoinsRet2; | CoinSet setCoinsRet, setCoinsRet2; | ||||
Amount nValueRet; | Amount nValueRet; | ||||
bool bnb_used; | bool bnb_used; | ||||
LOCK(testWallet.cs_wallet); | LOCK(testWallet.cs_wallet); | ||||
// test multiple times to allow for differences in the shuffle order | // test multiple times to allow for differences in the shuffle order | ||||
▲ Show 20 Lines • Show All 397 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(ApproximateBestSubset) { | ||||
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U); | BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U); | ||||
empty_wallet(); | empty_wallet(); | ||||
} | } | ||||
// Tests that with the ideal conditions, the coin selector will always be able | // Tests that with the ideal conditions, the coin selector will always be able | ||||
// to find a solution that can pay the target value | // to find a solution that can pay the target value | ||||
BOOST_AUTO_TEST_CASE(SelectCoins_test) { | BOOST_AUTO_TEST_CASE(SelectCoins_test) { | ||||
CWallet testWallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | CWallet testWallet(Params(), "dummy", WalletDatabase::CreateDummy()); | ||||
// Random generator stuff | // Random generator stuff | ||||
std::default_random_engine generator; | std::default_random_engine generator; | ||||
std::exponential_distribution<double> distribution(100); | std::exponential_distribution<double> distribution(100); | ||||
FastRandomContext rand; | FastRandomContext rand; | ||||
// Run this test 100 times | // Run this test 100 times | ||||
for (int i = 0; i < 100; ++i) { | for (int i = 0; i < 100; ++i) { | ||||
Show All 34 Lines |