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:
furszy 2023-07-07 10:14:03 -03:00
parent cf4da5ec29
commit 89ba8905f5
No known key found for this signature in database
GPG key ID: 5DD23CCC686AA623

View file

@ -5,11 +5,18 @@
#include <test/util/index.h>
#include <index/base.h>
#include <shutdown.h>
#include <util/check.h>
#include <util/time.h>
void IndexWaitSynced(const BaseIndex& index)
{
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);
}
assert(index.GetSummary().synced);
}