Skip to content

Commit d3d7535

Browse files
committed
Merge pull request #3578 from gavinandresen/unittest_debuglockorder
Unit test fixes for AssertLockHeld / -DDEBUG_LOCKORDER
2 parents d0a94f2 + fd67424 commit d3d7535

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/test/accounting_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
3434
CAccountingEntry ae;
3535
std::map<int64_t, CAccountingEntry> results;
3636

37+
LOCK(pwalletMain->cs_wallet);
38+
3739
ae.strAccount = "";
3840
ae.nCreditDebit = 1;
3941
ae.nTime = 1333333333;

src/test/rpc_wallet_tests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "rpcclient.h"
33

44
#include "base58.h"
5+
#include "wallet.h"
56

67
#include <boost/algorithm/string.hpp>
78
#include <boost/test/unit_test.hpp>
@@ -12,10 +13,14 @@ using namespace json_spirit;
1213
extern Array createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL);
1314
extern Value CallRPC(string args);
1415

16+
extern CWallet* pwalletMain;
17+
1518
BOOST_AUTO_TEST_SUITE(rpc_wallet_tests)
1619

1720
BOOST_AUTO_TEST_CASE(rpc_addmultisig)
1821
{
22+
LOCK(pwalletMain->cs_wallet);
23+
1924
rpcfn_type addmultisig = tableRPC["addmultisigaddress"]->actor;
2025

2126
// old, 65-byte-long:
@@ -56,6 +61,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
5661
// Test RPC calls for various wallet statistics
5762
Value r;
5863

64+
LOCK(pwalletMain->cs_wallet);
65+
5966
BOOST_CHECK_NO_THROW(CallRPC("listunspent"));
6067
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error);
6168
BOOST_CHECK_THROW(CallRPC("listunspent 0 string"), runtime_error);

src/test/wallet_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
6262
CoinSet setCoinsRet, setCoinsRet2;
6363
int64_t nValueRet;
6464

65+
LOCK(wallet.cs_wallet);
66+
6567
// test multiple times to allow for differences in the shuffle order
6668
for (int i = 0; i < RUN_TESTS; i++)
6769
{

0 commit comments

Comments
 (0)