test: Wait for index sync in all tests #36618

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2610-test-index-wallet-sync changing 18 files +41 −71
  1. maflcko commented at 8:49 AM on October 23, 2026: member

    Fixes #36564 by adding the missing wait on the index sync.

    Diff to reproduce:

    diff --git a/src/util/thread.cpp b/src/util/thread.cpp
    index 5b20e807b4..2e988c9eea 100644
    --- a/src/util/thread.cpp
    +++ b/src/util/thread.cpp
    @@ -8,2 +8,3 @@
     #include <util/log.h>
    +#include <util/time.h>
     #include <util/threadnames.h>
    @@ -17,2 +18,3 @@ void util::TraceThread(std::string_view thread_name, std::function<void()> threa
         util::ThreadRename(std::string{thread_name});
    +    UninterruptibleSleep(999ms);
         try {
    

    Command to reproduce (run twice to create the cache the first time, and reproduce on the second):

    ./bld-cmake/test/functional/wallet_fast_rescan.py | grep WARNING
    

    On failure, the log will say something like:

     - 2026-10-18T05:06:44.451973Z [http.01] [wallet/scan.cpp:142] [ShouldFetchBlock] [scan] Fast rescan: inspect block 200 [4c063a93914ec0cb1604297f2f601dab9b9342bf073e6b80e1c11efd71714e2e] (WARNING: block filter not found!)
    
  2. test: Wait for index sync in wallet_fast_rescan.py fa8009ba29
  3. DrahtBot added the label Tests on Oct 23, 2026
  4. DrahtBot commented at 8:49 AM on October 23, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK ViniciusCestarii, hebasto

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #36629 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36629.svg"></sub> (Add output script index and corresponding script history RPC by andrewtoth)
    • #36292 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36292.svg"></sub> (index: Delete old coinstats index directory on startup by fjahr)
    • #36257 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36257.svg"></sub> (qa: assert_equals -> assert_true/assert_false by hodlinator)
    • #36002 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36002.svg"></sub> (txindex: allow running in pruned mode by andrewtoth)
    • #33904 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/33904.svg"></sub> (rest: add interface for gettxspendingprevout rpc by kevkevinpal)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. test: refactor: Wait for index sync by default
    The tests already wait for the mempool and blocks after start and after
    mining, so they should wait for indexes as well to avoid intermittent
    test failures.
    
    This refactor does not change any test behavior.
    fa74dc72d9
  6. maflcko commented at 1:11 PM on October 23, 2026: member

    It seems a bit tedious to find and fix all of those issues by hand. Also, the tests will become overly verbose with all the manual syncs.

    The framework should do this by itself, so I pushed that refactor and removed all of the manual syncs in tests.

  7. in test/functional/feature_index_prune.py:1 in fa74dc72d9


    ViniciusCestarii commented at 4:31 PM on October 29, 2026:

    In "test: refactor: Wait for index sync by default" fa74dc72d942e1628cea3c143bb56eed1457bbce

    This changes test behavior. It used to check for absolute height and missing index.


    maflcko commented at 10:13 AM on October 30, 2026:

    I don't think it does change behavior. The implicit sync will use getblockcount as the absolute height, just like the test used the height before.

    Also, the test calls RPCs to fetch the index data, so if an index was missing, the test would fail, just like before.


    ViniciusCestarii commented at 11:45 AM on October 30, 2026:

    thanks for explaining! Makes sense.

  8. ViniciusCestarii commented at 4:46 PM on October 29, 2026: contributor

    Concept ACK, I like how cleaner it is. I also measured performance but saw no significant change.

    Commented a test that loses coverage with these changes.

  9. ViniciusCestarii commented at 11:49 AM on October 30, 2026: contributor

    ACK fa74dc72d942e1628cea3c143bb56eed1457bbce

  10. maflcko requested review from hebasto on Oct 30, 2026
  11. hebasto commented at 12:27 PM on October 30, 2026: member

    Diff to reproduce:...

    I’m not sure this is the right reproducer, as all the tests pass on my Ubuntu 26.04 machine.

    UPDATE. A bit unrelated to this PR, but that reproducer with a longer sleep triggered the following tests on my machine:

    feature_anchors.py                                     | ✖ Failed  | 12 s
    feature_config_args.py                                 | ✖ Failed  | 15 s
    tool_utxo_to_sqlite.py                                 | ✖ Failed  | 3 s
    

    UPDATE 2. Only tool_utxo_to_sqlite.py seems to have an issue, as others pass with the proper --timeout-factor.

    UPDATE 3. A clanker's fix:

    --- a/test/functional/tool_utxo_to_sqlite.py
    +++ b/test/functional/tool_utxo_to_sqlite.py
    @@ -119,6 +119,7 @@ class UtxoToSqliteTest(BitcoinTestFramework):
     
             self.log.info('Dump UTXO set via `dumptxoutset` RPC')
             input_filename = os.path.join(self.options.tmpdir, "utxos.dat")
    +        self.wait_until(lambda: node.getindexinfo()['coinstatsindex']['synced'])
             node.dumptxoutset(input_filename, "latest")
     
             for i, (txid_format, spk_format) in enumerate(product(["hex", "raw", "rawle"], ["hex", "raw"])):
    
  12. maflcko commented at 6:08 PM on October 30, 2026: member

    I’m not sure this is the right reproducer, as all the tests pass on my Ubuntu 26.04 machine.

    Sorry, I forgot to clarify this only reproduces when running the test stand-alone and on the second run, because it needs the cache.

  13. maflcko renamed this:
    test: Wait for index sync in wallet_fast_rescan.py
    test: Wait for index sync in all tests
    on Oct 30, 2026
  14. maflcko commented at 6:14 PM on October 30, 2026: member

    UPDATE 3. A clanker's fix:

    I don't understand. The pull request here is supposed to fix the all index sync test issue (and I've confirmed this locally for tool_utxo_to_sqlite.py as well). Can you try this again and confirm you tested this pull?

  15. hebasto commented at 3:38 PM on October 31, 2026: member

    I’m not sure this is the right reproducer, as all the tests pass on my Ubuntu 26.04 machine.

    Sorry, I forgot to clarify this only reproduces when running the test stand-alone and on the second run, because it needs the cache.

    I was able to reproduce the issue using a longer delay on another machine of mine, running Fedora 44.

    UPDATE 3. A clanker's fix:

    I don't understand. The pull request here is supposed to fix the all index sync test issue (and I've confirmed this locally for tool_utxo_to_sqlite.py as well). Can you try this again and confirm you tested this pull?

    Yes, I can confirm that I have been testing this PR yesterday and today :)

    It indeed fixes tool_utxo_to_sqlite.py as well. But the fix comes in the second commit. Its commit message reads "This refactor does not change any test behavior", but there is evidence that it is a fix rather than a pure refactor.

    To summarise, the extra delay in src/util/thread.cpp reliably triggers failures in both wallet_fast_rescan.py and tool_utxo_to_sqlite.py. The second commit fixes all of them. So is the first commit needed at all?

  16. maflcko commented at 6:02 PM on November 1, 2026: member

    It indeed fixes tool_utxo_to_sqlite.py as well. But the fix comes in the second commit. Its commit message reads "This refactor does not change any test behavior", but there is evidence that it is a fix rather than a pure refactor.

    I wasn't aware that other tests also need fixing and when I wrote this, it was meant as a hardening refactor. I don't think there is much value in spending too much time enumerating all tests that are fixed. This also fixes #35728 (review) and I am sure it fixes a bunch of others more.

    Happy to squash or reword the commit msg, but the overall diff won't change, so I am not sure if this is worth the review churn.

  17. hebasto approved
  18. hebasto commented at 11:31 AM on November 2, 2026: member

    ACK fa74dc72d942e1628cea3c143bb56eed1457bbce, the changes are correct.

    Happy to squash or reword the commit msg, but the overall diff won't change, so I am not sure if this is worth the review churn.

    You are right about the overall diff. However, I'd be happy to re-ACK if you change your mind about the imprecise commit message.

  19. fanquake merged this on Nov 2, 2026
  20. fanquake closed this on Nov 2, 2026

  21. maflcko deleted the branch on Nov 2, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-14 11:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me