aboutsummaryrefslogtreecommitdiff
path: root/src/test/util
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-28 12:20:05 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-06-28 12:45:36 +0200
commitfa086248e57b89cc549a090f727c0978082727c0 (patch)
tree284aebf40759728ea7b0fa591564906b5dbd29e2 /src/test/util
parent7ee41217b3b3fe4d8b7eb4fd1d4577b9b33d466d (diff)
test: Use same timeout for all index sync
Diffstat (limited to 'src/test/util')
-rw-r--r--src/test/util/index.cpp18
-rw-r--r--src/test/util/index.h13
2 files changed, 31 insertions, 0 deletions
diff --git a/src/test/util/index.cpp b/src/test/util/index.cpp
new file mode 100644
index 0000000000..2bda7b1773
--- /dev/null
+++ b/src/test/util/index.cpp
@@ -0,0 +1,18 @@
+// 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>
+#include <util/check.h>
+#include <util/time.h>
+
+void IndexWaitSynced(BaseIndex& index)
+{
+ const auto timeout{SteadyClock::now() + 120s};
+ while (!index.BlockUntilSyncedToCurrentChain()) {
+ Assert(timeout > SteadyClock::now());
+ UninterruptibleSleep(100ms);
+ }
+}
diff --git a/src/test/util/index.h b/src/test/util/index.h
new file mode 100644
index 0000000000..02030fd562
--- /dev/null
+++ b/src/test/util/index.h
@@ -0,0 +1,13 @@
+// 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.
+
+#ifndef BITCOIN_TEST_UTIL_INDEX_H
+#define BITCOIN_TEST_UTIL_INDEX_H
+
+class BaseIndex;
+
+/** Block until the index is synced to the current chain */
+void IndexWaitSynced(BaseIndex& index);
+
+#endif // BITCOIN_TEST_UTIL_INDEX_H