Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 785 Lines • ▼ Show 20 Lines | AddTx(CRecipient{GetScriptForRawPubKey({}), 1 * COIN, | ||||
false /* subtract fee */}); | false /* subtract fee */}); | ||||
list = wallet->ListCoins(); | list = wallet->ListCoins(); | ||||
BOOST_CHECK_EQUAL(list.size(), 1); | BOOST_CHECK_EQUAL(list.size(), 1); | ||||
BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), | BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), | ||||
coinbaseAddress); | coinbaseAddress); | ||||
BOOST_CHECK_EQUAL(list.begin()->second.size(), 2); | BOOST_CHECK_EQUAL(list.begin()->second.size(), 2); | ||||
// Lock both coins. Confirm number of available coins drops to 0. | // Lock both coins. Confirm number of available coins drops to 0. | ||||
{ | |||||
LOCK2(cs_main, wallet->cs_wallet); | |||||
std::vector<COutput> available; | std::vector<COutput> available; | ||||
wallet->AvailableCoins(available); | wallet->AvailableCoins(available); | ||||
BOOST_CHECK_EQUAL(available.size(), 2); | BOOST_CHECK_EQUAL(available.size(), 2); | ||||
} | |||||
for (const auto &group : list) { | for (const auto &group : list) { | ||||
for (const auto &coin : group.second) { | for (const auto &coin : group.second) { | ||||
LOCK(wallet->cs_wallet); | LOCK(wallet->cs_wallet); | ||||
wallet->LockCoin(COutPoint(coin.tx->GetId(), coin.i)); | wallet->LockCoin(COutPoint(coin.tx->GetId(), coin.i)); | ||||
} | } | ||||
} | } | ||||
{ | |||||
LOCK2(cs_main, wallet->cs_wallet); | |||||
std::vector<COutput> available; | |||||
wallet->AvailableCoins(available); | wallet->AvailableCoins(available); | ||||
BOOST_CHECK_EQUAL(available.size(), 0); | BOOST_CHECK_EQUAL(available.size(), 0); | ||||
} | |||||
// Confirm ListCoins still returns same result as before, despite coins | // Confirm ListCoins still returns same result as before, despite coins | ||||
// being locked. | // being locked. | ||||
list = wallet->ListCoins(); | list = wallet->ListCoins(); | ||||
BOOST_CHECK_EQUAL(list.size(), 1); | BOOST_CHECK_EQUAL(list.size(), 1); | ||||
BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), | BOOST_CHECK_EQUAL(boost::get<CKeyID>(list.begin()->first).ToString(), | ||||
coinbaseAddress); | coinbaseAddress); | ||||
BOOST_CHECK_EQUAL(list.begin()->second.size(), 2); | BOOST_CHECK_EQUAL(list.begin()->second.size(), 2); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |