refactor: Remove call to ShutdownRequested from IndexWaitSynced

Use the node interrupt object instead.

There is no change in behavior in this commit.
This commit is contained in:
Ryan Ofsky 2023-07-07 17:32:54 -04:00
parent 42e5829d97
commit ba93966368
5 changed files with 11 additions and 8 deletions

View file

@ -143,7 +143,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
BOOST_REQUIRE(filter_index.StartBackgroundSync());
// Allow filter index to catch up with the block index.
IndexWaitSynced(filter_index);
IndexWaitSynced(filter_index, *Assert(m_node.shutdown));
// Check that filter index has all blocks that were in the chain before it started.
{

View file

@ -35,7 +35,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
BOOST_REQUIRE(coin_stats_index.StartBackgroundSync());
IndexWaitSynced(coin_stats_index);
IndexWaitSynced(coin_stats_index, *Assert(m_node.shutdown));
// Check that CoinStatsIndex works for genesis block.
const CBlockIndex* genesis_block_index;
@ -86,7 +86,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_unclean_shutdown, TestChain100Setup)
CoinStatsIndex index{interfaces::MakeChain(m_node), 1 << 20};
BOOST_REQUIRE(index.Init());
BOOST_REQUIRE(index.StartBackgroundSync());
IndexWaitSynced(index);
IndexWaitSynced(index, *Assert(m_node.shutdown));
std::shared_ptr<const CBlock> new_block;
CBlockIndex* new_block_index = nullptr;
{

View file

@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
BOOST_REQUIRE(txindex.StartBackgroundSync());
// Allow tx index to catch up with the block index.
IndexWaitSynced(txindex);
IndexWaitSynced(txindex, *Assert(m_node.shutdown));
// Check that txindex excludes genesis block transactions.
const CBlock& genesis_block = Params().GenesisBlock();

View file

@ -5,16 +5,16 @@
#include <test/util/index.h>
#include <index/base.h>
#include <shutdown.h>
#include <util/check.h>
#include <util/signalinterrupt.h>
#include <util/time.h>
void IndexWaitSynced(const BaseIndex& index)
void IndexWaitSynced(const BaseIndex& index, const util::SignalInterrupt& interrupt)
{
while (!index.BlockUntilSyncedToCurrentChain()) {
// Assert shutdown was not requested to abort the test, instead of looping forever, in case
// there was an unexpected error in the index that caused it to stop syncing and request a shutdown.
Assert(!ShutdownRequested());
Assert(!interrupt);
UninterruptibleSleep(100ms);
}

View file

@ -6,8 +6,11 @@
#define BITCOIN_TEST_UTIL_INDEX_H
class BaseIndex;
namespace util {
class SignalInterrupt;
} // namespace util
/** Block until the index is synced to the current chain */
void IndexWaitSynced(const BaseIndex& index);
void IndexWaitSynced(const BaseIndex& index, const util::SignalInterrupt& interrupt);
#endif // BITCOIN_TEST_UTIL_INDEX_H