|
40 | 40 | #include <streams.h> |
41 | 41 | #include <spork.h> |
42 | 42 | #include <txdb.h> |
| 43 | +#include <test/util/index.h> |
43 | 44 | #include <util/strencodings.h> |
44 | 45 | #include <util/string.h> |
45 | 46 | #include <util/time.h> |
@@ -316,12 +317,7 @@ void TestChainSetup::mineBlocks(int num_blocks) |
316 | 317 | assert(g_txindex->Start(::ChainstateActive())); |
317 | 318 |
|
318 | 319 | // Allow tx index to catch up with the block index. |
319 | | - constexpr int64_t timeout_ms = 10 * 1000; |
320 | | - int64_t time_start = GetTimeMillis(); |
321 | | - while (!g_txindex->BlockUntilSyncedToCurrentChain()) { |
322 | | - assert(time_start + timeout_ms > GetTimeMillis()); |
323 | | - UninterruptibleSleep(std::chrono::milliseconds{100}); |
324 | | - } |
| 320 | + IndexWaitSynced(*g_txindex); |
325 | 321 | } |
326 | 322 |
|
327 | 323 | CBlock TestChainSetup::CreateAndProcessBlock(const std::vector<CMutableTransaction>& txns, const CScript& scriptPubKey) |
@@ -410,14 +406,9 @@ TestChainSetup::~TestChainSetup() |
410 | 406 | // Allow tx index to catch up with the block index cause otherwise |
411 | 407 | // we might be destroying it while scheduler still has some work for it |
412 | 408 | // e.g. via BlockConnected signal |
413 | | - int64_t time_start = GetTimeMillis(); |
414 | | - while (!g_txindex->BlockUntilSyncedToCurrentChain()) { |
415 | | - static constexpr int64_t timeout_ms = 10 * 1000; |
416 | | - assert(time_start + timeout_ms > GetTimeMillis()); |
417 | | - UninterruptibleSleep(std::chrono::milliseconds{100}); |
418 | | - } |
419 | | - g_txindex->Interrupt(); |
| 409 | + IndexWaitSynced(*g_txindex); |
420 | 410 | g_txindex->Stop(); |
| 411 | + SyncWithValidationInterfaceQueue(); |
421 | 412 | g_txindex.reset(); |
422 | 413 | SetMockTime(0); |
423 | 414 | } |
|
0 commit comments