From 89ba8905f5c68ae29412f9c4010314c5a113c234 Mon Sep 17 00:00:00 2001 From: furszy Date: Fri, 7 Jul 2023 10:14:03 -0300 Subject: 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. --- src/test/util/index.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/test/util/index.cpp') diff --git a/src/test/util/index.cpp b/src/test/util/index.cpp index 89bc35b731..e653d5dbf0 100644 --- a/src/test/util/index.cpp +++ b/src/test/util/index.cpp @@ -5,11 +5,18 @@ #include #include +#include +#include #include 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); } -- cgit v1.2.3