mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-25 22:34:27 +00:00
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.
This commit is contained in:
parent
d0a94f2c2f
commit
fd67424c82
@ -34,6 +34,8 @@ BOOST_AUTO_TEST_CASE(acc_orderupgrade)
|
|||||||
CAccountingEntry ae;
|
CAccountingEntry ae;
|
||||||
std::map<int64_t, CAccountingEntry> results;
|
std::map<int64_t, CAccountingEntry> results;
|
||||||
|
|
||||||
|
LOCK(pwalletMain->cs_wallet);
|
||||||
|
|
||||||
ae.strAccount = "";
|
ae.strAccount = "";
|
||||||
ae.nCreditDebit = 1;
|
ae.nCreditDebit = 1;
|
||||||
ae.nTime = 1333333333;
|
ae.nTime = 1333333333;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "rpcclient.h"
|
#include "rpcclient.h"
|
||||||
|
|
||||||
#include "base58.h"
|
#include "base58.h"
|
||||||
|
#include "wallet.h"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/test/unit_test.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 Array createArgs(int nRequired, const char* address1=NULL, const char* address2=NULL);
|
||||||
extern Value CallRPC(string args);
|
extern Value CallRPC(string args);
|
||||||
|
|
||||||
|
extern CWallet* pwalletMain;
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(rpc_wallet_tests)
|
BOOST_AUTO_TEST_SUITE(rpc_wallet_tests)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(rpc_addmultisig)
|
BOOST_AUTO_TEST_CASE(rpc_addmultisig)
|
||||||
{
|
{
|
||||||
|
LOCK(pwalletMain->cs_wallet);
|
||||||
|
|
||||||
rpcfn_type addmultisig = tableRPC["addmultisigaddress"]->actor;
|
rpcfn_type addmultisig = tableRPC["addmultisigaddress"]->actor;
|
||||||
|
|
||||||
// old, 65-byte-long:
|
// old, 65-byte-long:
|
||||||
@ -56,6 +61,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
|||||||
// Test RPC calls for various wallet statistics
|
// Test RPC calls for various wallet statistics
|
||||||
Value r;
|
Value r;
|
||||||
|
|
||||||
|
LOCK(pwalletMain->cs_wallet);
|
||||||
|
|
||||||
BOOST_CHECK_NO_THROW(CallRPC("listunspent"));
|
BOOST_CHECK_NO_THROW(CallRPC("listunspent"));
|
||||||
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error);
|
BOOST_CHECK_THROW(CallRPC("listunspent string"), runtime_error);
|
||||||
BOOST_CHECK_THROW(CallRPC("listunspent 0 string"), runtime_error);
|
BOOST_CHECK_THROW(CallRPC("listunspent 0 string"), runtime_error);
|
||||||
|
@ -62,6 +62,8 @@ BOOST_AUTO_TEST_CASE(coin_selection_tests)
|
|||||||
CoinSet setCoinsRet, setCoinsRet2;
|
CoinSet setCoinsRet, setCoinsRet2;
|
||||||
int64_t nValueRet;
|
int64_t nValueRet;
|
||||||
|
|
||||||
|
LOCK(wallet.cs_wallet);
|
||||||
|
|
||||||
// test multiple times to allow for differences in the shuffle order
|
// test multiple times to allow for differences in the shuffle order
|
||||||
for (int i = 0; i < RUN_TESTS; i++)
|
for (int i = 0; i < RUN_TESTS; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user