aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/test
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-01-19 16:08:03 -0500
committerRussell Yanofsky <russ@yanofsky.org>2018-03-07 21:12:47 -0500
commitb4bc32a451720167000f59dd73ab07990f9c6b92 (patch)
tree59dc966defd394bf338bd0d5e0546e97230692db /src/wallet/test
parenta128bdc9e15dec5cd9aed1e4922c938edf31eb9a (diff)
downloadbitcoin-b4bc32a451720167000f59dd73ab07990f9c6b92.tar.xz
[wallet] Get rid of CWalletTx default constructor
No change in behavior in the normal case. But buggy mapWallet lookups with invalid txids will now throw exceptions instead of inserting dummy entries into the map, and potentially causing segfaults and other failures. This also makes it a compiler error to use the mapWallet[hash] syntax which could create dummy entries.
Diffstat (limited to 'src/wallet/test')
-rw-r--r--src/wallet/test/accounting_tests.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/wallet/test/accounting_tests.cpp b/src/wallet/test/accounting_tests.cpp
index 7b20bd7b02..aae328d81f 100644
--- a/src/wallet/test/accounting_tests.cpp
+++ b/src/wallet/test/accounting_tests.cpp
@@ -29,7 +29,7 @@ GetResults(CWallet& wallet, std::map<CAmount, CAccountingEntry>& results)
BOOST_AUTO_TEST_CASE(acc_orderupgrade)
{
std::vector<CWalletTx*> vpwtx;
- CWalletTx wtx;
+ CWalletTx wtx(nullptr /* pwallet */, MakeTransactionRef());
CAccountingEntry ae;
std::map<CAmount, CAccountingEntry> results;
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
wtx.mapValue["comment"] = "z";
m_wallet.AddToWallet(wtx);
- vpwtx.push_back(&m_wallet.mapWallet[wtx.GetHash()]);
+ vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash()));
vpwtx[0]->nTimeReceived = (unsigned int)1333333335;
vpwtx[0]->nOrderPos = -1;
@@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
wtx.SetTx(MakeTransactionRef(std::move(tx)));
}
m_wallet.AddToWallet(wtx);
- vpwtx.push_back(&m_wallet.mapWallet[wtx.GetHash()]);
+ vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash()));
vpwtx[1]->nTimeReceived = (unsigned int)1333333336;
wtx.mapValue["comment"] = "x";
@@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
wtx.SetTx(MakeTransactionRef(std::move(tx)));
}
m_wallet.AddToWallet(wtx);
- vpwtx.push_back(&m_wallet.mapWallet[wtx.GetHash()]);
+ vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash()));
vpwtx[2]->nTimeReceived = (unsigned int)1333333329;
vpwtx[2]->nOrderPos = -1;