2023-06-28 12:20:05 +02:00
|
|
|
// Copyright (c) 2020-2022 The Bitcoin Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <test/util/index.h>
|
|
|
|
|
|
|
|
#include <index/base.h>
|
2023-07-07 10:14:03 -03:00
|
|
|
#include <util/check.h>
|
2023-07-07 17:32:54 -04:00
|
|
|
#include <util/signalinterrupt.h>
|
2023-06-28 12:20:05 +02:00
|
|
|
#include <util/time.h>
|
|
|
|
|
2023-07-07 17:32:54 -04:00
|
|
|
void IndexWaitSynced(const BaseIndex& index, const util::SignalInterrupt& interrupt)
|
2023-06-28 12:20:05 +02:00
|
|
|
{
|
|
|
|
while (!index.BlockUntilSyncedToCurrentChain()) {
|
2023-07-07 10:14:03 -03:00
|
|
|
// 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.
|
2023-07-07 17:32:54 -04:00
|
|
|
Assert(!interrupt);
|
2023-07-07 10:14:03 -03:00
|
|
|
|
2023-06-28 12:20:05 +02:00
|
|
|
UninterruptibleSleep(100ms);
|
|
|
|
}
|
2023-07-07 10:14:03 -03:00
|
|
|
assert(index.GetSummary().synced);
|
2023-06-28 12:20:05 +02:00
|
|
|
}
|