Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 719 Lines • ▼ Show 20 Lines | public: | ||||
~ListCoinsTestingSetup() { | ~ListCoinsTestingSetup() { | ||||
wallet.reset(); | wallet.reset(); | ||||
::bitdb.Flush(true); | ::bitdb.Flush(true); | ||||
::bitdb.Reset(); | ::bitdb.Reset(); | ||||
} | } | ||||
CWalletTx &AddTx(CRecipient recipient) { | CWalletTx &AddTx(CRecipient recipient) { | ||||
CWalletTx wtx; | CTransactionRef tx; | ||||
CReserveKey reservekey(wallet.get()); | CReserveKey reservekey(wallet.get()); | ||||
Amount fee; | Amount fee; | ||||
int changePos = -1; | int changePos = -1; | ||||
std::string error; | std::string error; | ||||
CCoinControl dummy; | CCoinControl dummy; | ||||
BOOST_CHECK(wallet->CreateTransaction({recipient}, wtx, reservekey, fee, | BOOST_CHECK(wallet->CreateTransaction({recipient}, tx, reservekey, fee, | ||||
changePos, error, dummy)); | changePos, error, dummy)); | ||||
CValidationState state; | CValidationState state; | ||||
BOOST_CHECK(wallet->CommitTransaction(wtx, reservekey, nullptr, state)); | BOOST_CHECK(wallet->CommitTransaction(tx, {}, {}, {}, reservekey, | ||||
nullptr, state)); | |||||
CMutableTransaction blocktx; | CMutableTransaction blocktx; | ||||
{ | { | ||||
LOCK(wallet->cs_wallet); | LOCK(wallet->cs_wallet); | ||||
blocktx = | blocktx = | ||||
CMutableTransaction(*wallet->mapWallet.at(wtx.GetId()).tx); | CMutableTransaction(*wallet->mapWallet.at(tx->GetId()).tx); | ||||
} | } | ||||
CreateAndProcessBlock({CMutableTransaction(blocktx)}, | CreateAndProcessBlock({CMutableTransaction(blocktx)}, | ||||
GetScriptForRawPubKey(coinbaseKey.GetPubKey())); | GetScriptForRawPubKey(coinbaseKey.GetPubKey())); | ||||
LOCK(wallet->cs_wallet); | LOCK(wallet->cs_wallet); | ||||
auto it = wallet->mapWallet.find(wtx.GetId()); | auto it = wallet->mapWallet.find(tx->GetId()); | ||||
BOOST_CHECK(it != wallet->mapWallet.end()); | BOOST_CHECK(it != wallet->mapWallet.end()); | ||||
it->second.SetMerkleBranch(chainActive.Tip(), 1); | it->second.SetMerkleBranch(chainActive.Tip(), 1); | ||||
return it->second; | return it->second; | ||||
} | } | ||||
std::unique_ptr<CWallet> wallet; | std::unique_ptr<CWallet> wallet; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |