Skip to content

Commit

Permalink
fix: resolve potential deadlock in coinjoin_tests
Browse files Browse the repository at this point in the history
ScanForWalletTransactions should be called outside of cs_wallet lock scope
  • Loading branch information
UdjinM6 committed Feb 22, 2025
1 parent 843a00d commit 2f5a466
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/wallet/test/coinjoin_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ class CTransactionBuilderTestSetup : public TestChain100Setup
LOCK2(wallet->cs_wallet, cs_main);
wallet->GetLegacyScriptPubKeyMan()->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey());
wallet->SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
WalletRescanReserver reserver(*wallet);
reserver.reserve();
CWallet::ScanResult result = wallet->ScanForWalletTransactions(m_node.chainman->ActiveChain().Genesis()->GetBlockHash(), 0 /* start_height */, {} /* max_height */, reserver, true /* fUpdate */);
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
}
WalletRescanReserver reserver(*wallet);
reserver.reserve();
CWallet::ScanResult result = wallet->ScanForWalletTransactions(/*start_block=*/wallet->chain().getBlockHash(0),
/*start_height=*/0, /*max_height=*/{}, reserver,
/*fUpdate=*/true);
BOOST_CHECK_EQUAL(result.status, CWallet::ScanResult::SUCCESS);
}

~CTransactionBuilderTestSetup()
Expand Down

0 comments on commit 2f5a466

Please sign in to comment.