aboutsummaryrefslogtreecommitdiff
path: root/src/test/rpc_wallet_tests.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2014-01-23 14:18:26 -0500
committerGavin Andresen <gavinandresen@gmail.com>2014-01-24 10:47:29 -0500
commitfd67424c829b9bb0ed7f4a53040524c560262810 (patch)
tree49585a6d81c8bd6fe625d49f8a4eee318a3d6da6 /src/test/rpc_wallet_tests.cpp
parentd0a94f2c2f127768acd9be4c0905d40f609ba6fc (diff)
Unit test fixes for AssertLockHeld / -DDEBUG_LOCKORDER
Unit tests would fail if compiled with -DDEBUG_LOCKORDER (AssertLockHeld() would fail; AssertLockHeld() relies on the DEBUG_LOCKORDER code to keep track of locks held). Fixed by LOCK'ing the wallet mutex in the unit tests that manipulate the wallet.
Diffstat (limited to 'src/test/rpc_wallet_tests.cpp')
-rw-r--r--src/test/rpc_wallet_tests.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp
index 2cf0fb350b..628ba95067 100644
--- a/src/test/rpc_wallet_tests.cpp
+++ b/src/test/rpc_wallet_tests.cpp
@@ -2,6 +2,7 @@
#include "rpcclient.h"
#include "base58.h"
+#include "wallet.h"
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
@@ -12,10 +13,14 @@ using namespace json_spirit;
extern Array createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL);
extern Value CallRPC(string args);
+extern CWallet* pwalletMain;
+
BOOST_AUTO_TEST_SUITE(rpc_wallet_tests)
BOOST_AUTO_TEST_CASE(rpc_addmultisig)
{
+ LOCK(pwalletMain->cs_wallet);
+
rpcfn_type addmultisig = tableRPC["addmultisigaddress"]->actor;
// old, 65-byte-long:
@@ -56,6 +61,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
// Test RPC calls for various wallet statistics
Value r;
+ LOCK(pwalletMain->cs_wallet);
+
BOOST_CHECK_NO_THROW(CallRPC("listunspent"));
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error);
BOOST_CHECK_THROW(CallRPC("listunspent 0 string"), runtime_error);