@@ -368,7 +368,10 @@ class ListCoinsTestingSetup : public TestChain100Setup
368
368
int changePos = -1 ;
369
369
std::string error;
370
370
CCoinControl dummy;
371
- BOOST_CHECK (wallet->CreateTransaction (*m_locked_chain, {recipient}, tx, reservekey, fee, changePos, error, dummy));
371
+ {
372
+ auto locked_chain = m_chain->lock ();
373
+ BOOST_CHECK (wallet->CreateTransaction (*locked_chain, {recipient}, tx, reservekey, fee, changePos, error, dummy));
374
+ }
372
375
CValidationState state;
373
376
BOOST_CHECK (wallet->CommitTransaction (tx, {}, {}, reservekey, state));
374
377
CMutableTransaction blocktx;
@@ -387,7 +390,6 @@ class ListCoinsTestingSetup : public TestChain100Setup
387
390
}
388
391
389
392
std::unique_ptr<interfaces::Chain> m_chain = interfaces::MakeChain();
390
- std::unique_ptr<interfaces::Chain::Lock> m_locked_chain = m_chain->assumeLocked (); // Temporary. Removed in upcoming lock cleanup
391
393
std::unique_ptr<CWallet> wallet;
392
394
};
393
395
@@ -399,8 +401,9 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
399
401
// address.
400
402
std::map<CTxDestination, std::vector<COutput>> list;
401
403
{
402
- LOCK2 (cs_main, wallet->cs_wallet );
403
- list = wallet->ListCoins (*m_locked_chain);
404
+ auto locked_chain = m_chain->lock ();
405
+ LOCK (wallet->cs_wallet );
406
+ list = wallet->ListCoins (*locked_chain);
404
407
}
405
408
BOOST_CHECK_EQUAL (list.size (), 1U );
406
409
BOOST_CHECK_EQUAL (boost::get<PKHash>(list.begin ()->first ).ToString (), coinbaseAddress);
@@ -415,18 +418,20 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
415
418
// pubkey.
416
419
AddTx (CRecipient{GetScriptForRawPubKey ({}), 1 * COIN, false /* subtract fee */ });
417
420
{
418
- LOCK2 (cs_main, wallet->cs_wallet );
419
- list = wallet->ListCoins (*m_locked_chain);
421
+ auto locked_chain = m_chain->lock ();
422
+ LOCK (wallet->cs_wallet );
423
+ list = wallet->ListCoins (*locked_chain);
420
424
}
421
425
BOOST_CHECK_EQUAL (list.size (), 1U );
422
426
BOOST_CHECK_EQUAL (boost::get<PKHash>(list.begin ()->first ).ToString (), coinbaseAddress);
423
427
BOOST_CHECK_EQUAL (list.begin ()->second .size (), 2U );
424
428
425
429
// Lock both coins. Confirm number of available coins drops to 0.
426
430
{
427
- LOCK2 (cs_main, wallet->cs_wallet );
431
+ auto locked_chain = m_chain->lock ();
432
+ LOCK (wallet->cs_wallet );
428
433
std::vector<COutput> available;
429
- wallet->AvailableCoins (*m_locked_chain , available);
434
+ wallet->AvailableCoins (*locked_chain , available);
430
435
BOOST_CHECK_EQUAL (available.size (), 2U );
431
436
}
432
437
for (const auto & group : list) {
@@ -436,16 +441,18 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup)
436
441
}
437
442
}
438
443
{
439
- LOCK2 (cs_main, wallet->cs_wallet );
444
+ auto locked_chain = m_chain->lock ();
445
+ LOCK (wallet->cs_wallet );
440
446
std::vector<COutput> available;
441
- wallet->AvailableCoins (*m_locked_chain , available);
447
+ wallet->AvailableCoins (*locked_chain , available);
442
448
BOOST_CHECK_EQUAL (available.size (), 0U );
443
449
}
444
450
// Confirm ListCoins still returns same result as before, despite coins
445
451
// being locked.
446
452
{
447
- LOCK2 (cs_main, wallet->cs_wallet );
448
- list = wallet->ListCoins (*m_locked_chain);
453
+ auto locked_chain = m_chain->lock ();
454
+ LOCK (wallet->cs_wallet );
455
+ list = wallet->ListCoins (*locked_chain);
449
456
}
450
457
BOOST_CHECK_EQUAL (list.size (), 1U );
451
458
BOOST_CHECK_EQUAL (boost::get<PKHash>(list.begin ()->first ).ToString (), coinbaseAddress);
0 commit comments