aboutsummaryrefslogtreecommitdiff
path: root/src/test/util/index.cpp
diff options
context:
space:
mode:
authorfurszy <matiasfurszyfer@protonmail.com>2023-07-07 10:14:03 -0300
committerfurszy <matiasfurszyfer@protonmail.com>2023-07-10 15:27:13 -0300
commit89ba8905f5c68ae29412f9c4010314c5a113c234 (patch)
tree363729ece0b320aab2efcf031f51791507382140 /src/test/util/index.cpp
parentcf4da5ec29f9e8cd6cc6577e5ecbd87174edba62 (diff)
downloadbitcoin-89ba8905f5c68ae29412f9c4010314c5a113c234.tar.xz
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.
Diffstat (limited to 'src/test/util/index.cpp')
-rw-r--r--src/test/util/index.cpp7
1 files changed, 7 insertions, 0 deletions
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 <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);
}