Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,184 Lines • ▼ Show 20 Lines | for (const auto &entry : mapWallet) { | ||||
const CWalletTx *pcoin = &entry.second; | const CWalletTx *pcoin = &entry.second; | ||||
if (pcoin->IsTrusted()) { | if (pcoin->IsTrusted()) { | ||||
nTotal += pcoin->GetAvailableCredit(); | nTotal += pcoin->GetAvailableCredit(); | ||||
} | } | ||||
} | } | ||||
return nTotal; | return nTotal; | ||||
} | } | ||||
bool CWallet::CheckBalance(Amount toSpend) const { | |||||
deadalnix: You need to unit test that guy.
Please add a new line before the function definition. | |||||
jtoomimAuthorUnsubmitted Done Inline ActionsThere are no unit tests in src/wallet/tests/ that create transactions for which the IsTrusted() check can be passed. There are no unit tests in src/tests/ that have any wallet code. I spent a couple hours trying to hack something together on Monday with no success yet. Core has some new wallet unit tests that look like they will be easier to add a CheckBalance test to, but they have several other commits as dependencies and are not conducive to cherry picking or copy-pasting. I'll take a look at the unit tests again later, but I won't have time for this for a while, maybe a week. :/ jtoomim: There are no unit tests in src/wallet/tests/ that create transactions for which the IsTrusted()… | |||||
LOCK2(cs_main, cs_wallet); | |||||
Amount nTotal = Amount::zero(); | |||||
for (const auto &entry : mapWallet) { | |||||
const CWalletTx *pcoin = &entry.second; | |||||
if (pcoin->IsTrusted()) { | |||||
nTotal += pcoin->GetAvailableCredit(); | |||||
if (nTotal >= toSpend) { | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
Amount CWallet::GetUnconfirmedBalance() const { | Amount CWallet::GetUnconfirmedBalance() const { | ||||
LOCK2(cs_main, cs_wallet); | LOCK2(cs_main, cs_wallet); | ||||
Amount nTotal = Amount::zero(); | Amount nTotal = Amount::zero(); | ||||
for (const auto &entry : mapWallet) { | for (const auto &entry : mapWallet) { | ||||
const CWalletTx *pcoin = &entry.second; | const CWalletTx *pcoin = &entry.second; | ||||
if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && | if (!pcoin->IsTrusted() && pcoin->GetDepthInMainChain() == 0 && | ||||
▲ Show 20 Lines • Show All 2,311 Lines • Show Last 20 Lines |
You need to unit test that guy.
Please add a new line before the function definition.