mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-08-27 07:43:59 +02:00
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:
@@ -143,7 +143,7 @@ BOOST_FIXTURE_TEST_CASE(blockfilter_index_initial_sync, BuildChainTestingSetup)
|
|||||||
BOOST_REQUIRE(filter_index.StartBackgroundSync());
|
BOOST_REQUIRE(filter_index.StartBackgroundSync());
|
||||||
|
|
||||||
// Allow filter index to catch up with the block index.
|
// 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.
|
// Check that filter index has all blocks that were in the chain before it started.
|
||||||
{
|
{
|
||||||
|
@@ -35,7 +35,7 @@ BOOST_FIXTURE_TEST_CASE(coinstatsindex_initial_sync, TestChain100Setup)
|
|||||||
|
|
||||||
BOOST_REQUIRE(coin_stats_index.StartBackgroundSync());
|
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.
|
// Check that CoinStatsIndex works for genesis block.
|
||||||
const CBlockIndex* genesis_block_index;
|
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};
|
CoinStatsIndex index{interfaces::MakeChain(m_node), 1 << 20};
|
||||||
BOOST_REQUIRE(index.Init());
|
BOOST_REQUIRE(index.Init());
|
||||||
BOOST_REQUIRE(index.StartBackgroundSync());
|
BOOST_REQUIRE(index.StartBackgroundSync());
|
||||||
IndexWaitSynced(index);
|
IndexWaitSynced(index, *Assert(m_node.shutdown));
|
||||||
std::shared_ptr<const CBlock> new_block;
|
std::shared_ptr<const CBlock> new_block;
|
||||||
CBlockIndex* new_block_index = nullptr;
|
CBlockIndex* new_block_index = nullptr;
|
||||||
{
|
{
|
||||||
|
@@ -33,7 +33,7 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
|
|||||||
BOOST_REQUIRE(txindex.StartBackgroundSync());
|
BOOST_REQUIRE(txindex.StartBackgroundSync());
|
||||||
|
|
||||||
// Allow tx index to catch up with the block index.
|
// 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.
|
// Check that txindex excludes genesis block transactions.
|
||||||
const CBlock& genesis_block = Params().GenesisBlock();
|
const CBlock& genesis_block = Params().GenesisBlock();
|
||||||
|
@@ -5,16 +5,16 @@
|
|||||||
#include <test/util/index.h>
|
#include <test/util/index.h>
|
||||||
|
|
||||||
#include <index/base.h>
|
#include <index/base.h>
|
||||||
#include <shutdown.h>
|
|
||||||
#include <util/check.h>
|
#include <util/check.h>
|
||||||
|
#include <util/signalinterrupt.h>
|
||||||
#include <util/time.h>
|
#include <util/time.h>
|
||||||
|
|
||||||
void IndexWaitSynced(const BaseIndex& index)
|
void IndexWaitSynced(const BaseIndex& index, const util::SignalInterrupt& interrupt)
|
||||||
{
|
{
|
||||||
while (!index.BlockUntilSyncedToCurrentChain()) {
|
while (!index.BlockUntilSyncedToCurrentChain()) {
|
||||||
// Assert shutdown was not requested to abort the test, instead of looping forever, in case
|
// 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.
|
// there was an unexpected error in the index that caused it to stop syncing and request a shutdown.
|
||||||
Assert(!ShutdownRequested());
|
Assert(!interrupt);
|
||||||
|
|
||||||
UninterruptibleSleep(100ms);
|
UninterruptibleSleep(100ms);
|
||||||
}
|
}
|
||||||
|
@@ -6,8 +6,11 @@
|
|||||||
#define BITCOIN_TEST_UTIL_INDEX_H
|
#define BITCOIN_TEST_UTIL_INDEX_H
|
||||||
|
|
||||||
class BaseIndex;
|
class BaseIndex;
|
||||||
|
namespace util {
|
||||||
|
class SignalInterrupt;
|
||||||
|
} // namespace util
|
||||||
|
|
||||||
/** Block until the index is synced to the current chain */
|
/** 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
|
#endif // BITCOIN_TEST_UTIL_INDEX_H
|
||||||
|
Reference in New Issue
Block a user