@@ -87,7 +87,10 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
8787 }
8888
8989 // Prune the older block file.
90- EnsureChainman (m_node).PruneOneBlockFile (oldTip->GetBlockPos ().nFile );
90+ {
91+ LOCK (cs_main);
92+ EnsureChainman (m_node).PruneOneBlockFile (oldTip->GetBlockPos ().nFile );
93+ }
9194 UnlinkPrunedFiles ({oldTip->GetBlockPos ().nFile });
9295
9396 // Verify ScanForWalletTransactions only picks transactions in the new block
@@ -110,7 +113,10 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
110113 }
111114
112115 // Prune the remaining block file.
113- EnsureChainman (m_node).PruneOneBlockFile (newTip->GetBlockPos ().nFile );
116+ {
117+ LOCK (cs_main);
118+ EnsureChainman (m_node).PruneOneBlockFile (newTip->GetBlockPos ().nFile );
119+ }
114120 UnlinkPrunedFiles ({newTip->GetBlockPos ().nFile });
115121
116122 // Verify ScanForWalletTransactions scans no blocks.
@@ -145,7 +151,10 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
145151 LockAnnotation lock (::cs_main);
146152
147153 // Prune the older block file.
148- EnsureChainman (m_node).PruneOneBlockFile (oldTip->GetBlockPos ().nFile );
154+ {
155+ LOCK (cs_main);
156+ EnsureChainman (m_node).PruneOneBlockFile (oldTip->GetBlockPos ().nFile );
157+ }
149158 UnlinkPrunedFiles ({oldTip->GetBlockPos ().nFile });
150159
151160 // Verify importmulti RPC returns failure for a key whose creation time is
@@ -397,10 +406,11 @@ class ListCoinsTestingSetup : public TestChain100Setup
397406 int changePos = -1 ;
398407 bilingual_str error;
399408 CCoinControl dummy;
409+ BOOST_CHECK (wallet->CreateTransaction ({recipient}, tx, fee, changePos, error, dummy));
400410 {
401- BOOST_CHECK (wallet->CreateTransaction ({recipient}, tx, fee, changePos, error, dummy));
411+ LOCK2 (wallet->cs_wallet , cs_main);
412+ wallet->CommitTransaction (tx, {}, {});
402413 }
403- wallet->CommitTransaction (tx, {}, {});
404414 CMutableTransaction blocktx;
405415 {
406416 LOCK (wallet->cs_wallet );
@@ -611,7 +621,10 @@ class CreateTransactionTestSetup : public TestChain100Setup
611621 bilingual_str strError;
612622 CCoinControl coinControl;
613623 BOOST_CHECK (wallet->CreateTransaction (GetRecipients (vecEntries), tx, nFeeRet, nChangePosRet, strError, coinControl));
614- wallet->CommitTransaction (tx, {}, {});
624+ {
625+ LOCK2 (wallet->cs_wallet , cs_main);
626+ wallet->CommitTransaction (tx, {}, {});
627+ }
615628 CMutableTransaction blocktx;
616629 {
617630 LOCK (wallet->cs_wallet );
@@ -945,16 +958,16 @@ BOOST_FIXTURE_TEST_CASE(select_coins_grouped_by_addresses, ListCoinsTestingSetup
945958 int changePos = -1 ;
946959 bilingual_str error;
947960 CCoinControl dummy;
961+ BOOST_CHECK (wallet->CreateTransaction ({CRecipient{GetScriptForRawPubKey ({}), 2 * COIN, true /* subtract fee */ }},
962+ tx1, fee, changePos, error, dummy));
963+ BOOST_CHECK (wallet->CreateTransaction ({CRecipient{GetScriptForRawPubKey ({}), 1 * COIN, true /* subtract fee */ }},
964+ tx2, fee, changePos, error, dummy));
948965 {
949- BOOST_CHECK (wallet->CreateTransaction ({CRecipient{GetScriptForRawPubKey ({}), 2 * COIN, true /* subtract fee */ }},
950- tx1, fee, changePos, error, dummy));
951- BOOST_CHECK (wallet->CreateTransaction ({CRecipient{GetScriptForRawPubKey ({}), 1 * COIN, true /* subtract fee */ }},
952- tx2, fee, changePos, error, dummy));
966+ LOCK2 (wallet->cs_wallet , cs_main);
967+ wallet->CommitTransaction (tx1, {}, {});
953968 }
954- wallet->CommitTransaction (tx1, {}, {});
955969 BOOST_CHECK_EQUAL (wallet->GetAvailableBalance (), 0 );
956970 CreateAndProcessBlock ({CMutableTransaction (*tx2)}, GetScriptForRawPubKey ({}));
957-
958971 {
959972 LOCK2 (wallet->cs_wallet , cs_main);
960973 wallet->SetLastBlockProcessed (::ChainActive ().Height (), ::ChainActive ().Tip ()->GetBlockHash ());
0 commit comments