mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
test: indexes, fix on error infinite loop
As index sync failures trigger a shutdown request without notifying BaseIndex::BlockUntilSyncedToCurrentChain in any way, we also need to check whether a shutdown was requested or not inside 'IndexWaitSynced'. Otherwise, any error inside the index sync process will hang the test forever.
This commit is contained in:
parent
cf4da5ec29
commit
89ba8905f5
1 changed files with 7 additions and 0 deletions
|
@ -5,11 +5,18 @@
|
||||||
#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/time.h>
|
#include <util/time.h>
|
||||||
|
|
||||||
void IndexWaitSynced(const BaseIndex& index)
|
void IndexWaitSynced(const BaseIndex& index)
|
||||||
{
|
{
|
||||||
while (!index.BlockUntilSyncedToCurrentChain()) {
|
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());
|
||||||
|
|
||||||
UninterruptibleSleep(100ms);
|
UninterruptibleSleep(100ms);
|
||||||
}
|
}
|
||||||
|
assert(index.GetSummary().synced);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue