test: indexes, avoid creating threads when sync runs synchronously

The indexes test call StartBackgroundSync(), which spawns a thread to run Sync(),
only for the test thread to wait for it to complete by calling IndexWaitSynced().

So, since the sync is performed synchronously, we can skip the extra thread creation
entirely and call Sync() directly.
This commit is contained in:
furszy
2025-06-06 14:24:46 -04:00
parent ae024137bd
commit 331a25cb16
6 changed files with 4 additions and 55 deletions

View File

@@ -6,7 +6,6 @@
#include <chainparams.h>
#include <index/txindex.h>
#include <interfaces/chain.h>
#include <test/util/index.h>
#include <test/util/setup_common.h>
#include <validation.h>
@@ -30,10 +29,7 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
// BlockUntilSyncedToCurrentChain should return false before txindex is started.
BOOST_CHECK(!txindex.BlockUntilSyncedToCurrentChain());
BOOST_REQUIRE(txindex.StartBackgroundSync());
// Allow tx index to catch up with the block index.
IndexWaitSynced(txindex, *Assert(m_node.shutdown_signal));
txindex.Sync();
// Check that txindex excludes genesis block transactions.
const CBlock& genesis_block = Params().GenesisBlock();