{
 "number": 36618,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36618",
 "title": "test: Wait for index sync in all tests",
 "author": "maflcko",
 "author_association": "MEMBER",
 "created_at": "2026-10-23T08:49:27Z",
 "updated_at": "2026-11-01T18:02:57Z",
 "description_hash": "69aa16051aa72315",
 "age_days": 9,
 "draft": false,
 "labels": [
  "Tests"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
 "head_ref": "2610-test-index-wallet-sync",
 "head_repo": "maflcko/bitcoin-core",
 "head_history": [],
 "additions": 41,
 "deletions": 71,
 "changed_files": 18,
 "commit_count": 2,
 "size_bucket": "M",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {
    "ack": [
     {
      "login": "ViniciusCestarii",
      "url": "https://github.com/bitcoin/bitcoin/pull/36618#pullrequestreview-5711794977"
     }
    ]
   },
   "conflicts": []
  }
 },
 "acks_parsed": {
  "ViniciusCestarii": {
   "kind": "ack",
   "hash": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "t": "2026-10-30T11:49:18Z",
   "stale": false
  }
 },
 "acks_tally": {
  "ack": 1,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "ViniciusCestarii",
   "hebasto"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-11-01T18:02:57Z",
  "last_reviewer_activity": "2026-10-31T15:38:54Z",
  "last_reviewer": "hebasto",
  "author_silent_days": 0,
  "waiting_on_author_days": 0,
  "days_since_update": 0
 },
 "refs": {
  "mentioned": [],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "test/functional/feature_index_prune.py"
 ],
 "body": "Fixes https://github.com/bitcoin/bitcoin/issues/36564 by adding the missing wait on the index sync.\n\nDiff to reproduce:\n\n```diff\ndiff --git a/src/util/thread.cpp b/src/util/thread.cpp\nindex 5b20e807b4..2e988c9eea 100644\n--- a/src/util/thread.cpp\n+++ b/src/util/thread.cpp\n@@ -8,2 +8,3 @@\n #include <util/log.h>\n+#include <util/time.h>\n #include <util/threadnames.h>\n@@ -17,2 +18,3 @@ void util::TraceThread(std::string_view thread_name, std::function<void()> threa\n     util::ThreadRename(std::string{thread_name});\n+    UninterruptibleSleep(999ms);\n     try {\n```\n\nCommand to reproduce (run twice to create the cache the first time, and reproduce on the second):\n\n```\n./bld-cmake/test/functional/wallet_fast_rescan.py | grep WARNING\n```\n\nOn failure, the log will say something like:\n\n```\n - 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!)",
 "commits": [
  {
   "sha": "fa8009ba2997a0eb3e6e1a657db507e5a8b8b529",
   "date": "2026-10-23T08:47:01Z",
   "message": "test: Wait for index sync in wallet_fast_rescan.py"
  },
  {
   "sha": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "date": "2026-10-23T13:08:27Z",
   "message": "test: refactor: Wait for index sync by default\n\nThe tests already wait for the mempool and blocks after start and after\nmining, so they should wait for indexes as well to avoid intermittent\ntest failures.\n\nThis refactor does not change any test behavior."
  }
 ],
 "timeline": [
  {
   "t": "2026-10-23T13:11:25Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "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.\n\nThe framework should do this by itself, so I pushed that refactor and removed all of the manual syncs in tests.",
   "id": "c:6365669137",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#issuecomment-6365669137",
   "hash": "60977585cb75ee57",
   "edited": null
  },
  {
   "t": "2026-10-29T16:31:45Z",
   "kind": "review_comment",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "path": "test/functional/feature_index_prune.py",
   "commit": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "in_reply_to": null,
   "text": "In \"test: refactor: Wait for index sync by default\" fa74dc72d942e1628cea3c143bb56eed1457bbce\n\nThis changes test behavior. It used to check for absolute height and missing index.",
   "id": "rc:4415070983",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#discussion_r4415070983",
   "hash": "239bd4b6e2e658cf",
   "edited": "2026-10-29T16:46:07Z"
  },
  {
   "t": "2026-10-29T16:46:07Z",
   "kind": "review",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "text": "Concept ACK, I like how cleaner it is.  I also measured performance but saw no significant change.\n\n~~Commented a test that loses coverage with these changes.~~",
   "id": "r:5701332641",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#pullrequestreview-5701332641",
   "hash": "9177032e31379514",
   "edited": "2026-10-30T11:46:36Z"
  },
  {
   "t": "2026-10-30T10:13:34Z",
   "kind": "review_comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "path": "test/functional/feature_index_prune.py",
   "commit": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "in_reply_to": 4415070983,
   "text": "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.\n\nAlso, the test calls RPCs to fetch the index data, so if an index was missing, the test would fail, just like before.",
   "id": "rc:4422553940",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#discussion_r4422553940",
   "hash": "60409071c87068f3",
   "edited": "2026-10-30T10:13:35Z"
  },
  {
   "t": "2026-10-30T11:45:00Z",
   "kind": "review_comment",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "path": "test/functional/feature_index_prune.py",
   "commit": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "in_reply_to": 4415070983,
   "text": "thanks for explaining! Makes sense.",
   "id": "rc:4423245131",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#discussion_r4423245131",
   "hash": "2a120b4f8c36b390",
   "edited": "2026-10-30T11:45:01Z"
  },
  {
   "t": "2026-10-30T11:49:18Z",
   "kind": "review",
   "who": "ViniciusCestarii",
   "assoc": "CONTRIBUTOR",
   "state": "COMMENTED",
   "commit": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "text": "ACK fa74dc72d942e1628cea3c143bb56eed1457bbce",
   "id": "r:5711794977",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#pullrequestreview-5711794977",
   "hash": "c9799544e1088f3f",
   "edited": null
  },
  {
   "t": "2026-10-30T12:27:30Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nI\u2019m not sure this is the right reproducer, as all the tests pass on my Ubuntu 26.04 machine.\n\nUPDATE. A bit unrelated to this PR, but that reproducer with a longer sleep triggered the following tests on my machine:\n```\nfeature_anchors.py                                     | \u2716 Failed  | 12 s\nfeature_config_args.py                                 | \u2716 Failed  | 15 s\ntool_utxo_to_sqlite.py                                 | \u2716 Failed  | 3 s\n```\n\nUPDATE 2. Only `tool_utxo_to_sqlite.py` seems to have an issue, as others pass with the proper `--timeout-factor`.\n\nUPDATE 3. A clanker's fix:\n```diff\n--- a/test/functional/tool_utxo_to_sqlite.py\n+++ b/test/functional/tool_utxo_to_sqlite.py\n@@ -119,6 +119,7 @@ class UtxoToSqliteTest(BitcoinTestFramework):\n\n         self.log.info('Dump UTXO set via `dumptxoutset` RPC')\n         input_filename = os.path.join(self.options.tmpdir, \"utxos.dat\")\n+        self.wait_until(lambda: node.getindexinfo()['coinstatsindex']['synced'])\n         node.dumptxoutset(input_filename, \"latest\")\n\n         for i, (txid_format, spk_format) in enumerate(product([\"hex\", \"raw\", \"rawle\"], [\"hex\", \"raw\"])):\n```",
   "id": "c:6522836404",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#issuecomment-6522836404",
   "hash": "11cb7af21595318e",
   "edited": "2026-10-30T12:54:52Z"
  },
  {
   "t": "2026-10-30T18:08:14Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nSorry, I forgot to clarify this only reproduces when running the test stand-alone and on the second run, because it needs the cache.",
   "id": "c:6530030342",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#issuecomment-6530030342",
   "hash": "3c599961a2c4b185",
   "edited": null
  },
  {
   "t": "2026-10-30T18:14:22Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nI 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?",
   "id": "c:6530160749",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#issuecomment-6530160749",
   "hash": "df6f55e28c730765",
   "edited": null
  },
  {
   "t": "2026-10-31T15:38:54Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nI was able to reproduce the issue using a longer delay on another machine of mine, running Fedora 44.\n\n[quoted text omitted]\nYes, I can confirm that I have been testing this PR yesterday and today :)\n\nIt 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.\n\nTo 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?",
   "id": "c:6545513372",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#issuecomment-6545513372",
   "hash": "acdbc242654f29df",
   "edited": null
  },
  {
   "t": "2026-11-01T18:02:57Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nI 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 https://github.com/bitcoin/bitcoin/pull/35728#discussion_r4424117298 and I am sure it fixes a bunch of others more.\n\nHappy 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.",
   "id": "c:6561772062",
   "url": "https://github.com/bitcoin/bitcoin/pull/36618#issuecomment-6561772062",
   "hash": "33efcd3e446385ca",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-23T08:49:32Z",
   "action": "labeled",
   "label": "Tests",
   "who": "DrahtBot"
  }
 ],
 "state_log": [
  {
   "t": "2026-10-30T18:13:53Z",
   "kind": "renamed",
   "who": "maflcko",
   "from": "test: Wait for index sync in wallet_fast_rescan.py",
   "to": "test: Wait for index sync in all tests"
  }
 ],
 "text_chars": 5019,
 "text_tokens_estimate": 1254,
 "changed_paths": [
  "test/functional/feature_assumeutxo.py",
  "test/functional/feature_coinstatsindex.py",
  "test/functional/feature_coinstatsindex_compatibility.py",
  "test/functional/feature_index_prune.py",
  "test/functional/feature_init.py",
  "test/functional/feature_reindex.py",
  "test/functional/feature_txindex_compatibility.py",
  "test/functional/interface_rest.py",
  "test/functional/mempool_accept.py",
  "test/functional/rpc_gettxspendingprevout.py",
  "test/functional/rpc_misc.py",
  "test/functional/rpc_rawtransaction.py",
  "test/functional/rpc_scanblocks.py",
  "test/functional/rpc_txoutproof.py",
  "test/functional/rpc_whitelist.py",
  "test/functional/test_framework/test_framework.py",
  "test/functional/test_framework/test_node.py",
  "test/functional/test_framework/util.py"
 ],
 "files": [
  {
   "path": "test/functional/feature_assumeutxo.py",
   "add": 1,
   "del": 1
  },
  {
   "path": "test/functional/feature_coinstatsindex.py",
   "add": 1,
   "del": 6
  },
  {
   "path": "test/functional/feature_coinstatsindex_compatibility.py",
   "add": 0,
   "del": 3
  },
  {
   "path": "test/functional/feature_index_prune.py",
   "add": 1,
   "del": 19
  },
  {
   "path": "test/functional/feature_init.py",
   "add": 0,
   "del": 1
  },
  {
   "path": "test/functional/feature_reindex.py",
   "add": 2,
   "del": 2
  },
  {
   "path": "test/functional/feature_txindex_compatibility.py",
   "add": 1,
   "del": 5
  },
  {
   "path": "test/functional/interface_rest.py",
   "add": 0,
   "del": 6
  },
  {
   "path": "test/functional/mempool_accept.py",
   "add": 0,
   "del": 2
  },
  {
   "path": "test/functional/rpc_gettxspendingprevout.py",
   "add": 0,
   "del": 2
  },
  {
   "path": "test/functional/rpc_misc.py",
   "add": 1,
   "del": 2
  },
  {
   "path": "test/functional/rpc_rawtransaction.py",
   "add": 0,
   "del": 2
  },
  {
   "path": "test/functional/rpc_scanblocks.py",
   "add": 0,
   "del": 1
  },
  {
   "path": "test/functional/rpc_txoutproof.py",
   "add": 0,
   "del": 2
  },
  {
   "path": "test/functional/rpc_whitelist.py",
   "add": 1,
   "del": 1
  },
  {
   "path": "test/functional/test_framework/test_framework.py",
   "add": 15,
   "del": 7
  },
  {
   "path": "test/functional/test_framework/test_node.py",
   "add": 18,
   "del": 3
  },
  {
   "path": "test/functional/test_framework/util.py",
   "add": 0,
   "del": 6
  }
 ],
 "test_lines": 112,
 "git": {
  "head": "fa74dc72d942e1628cea3c143bb56eed1457bbce",
  "head_matches_backup": true,
  "base": "152a55397e451fed9c10041bddf01aa6839847d5",
  "patch_id": "f2fb2b035764d919",
  "commits": [
   {
    "sha": "fa8009ba29",
    "subject": "test: Wait for index sync in wallet_fast_rescan.py",
    "files": 1,
    "add": 1,
    "del": 0
   },
   {
    "sha": "fa74dc72d9",
    "subject": "test: refactor: Wait for index sync by default",
    "files": 19,
    "add": 41,
    "del": 72
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "f2fb2b035764d919",
 "input_hash": "03ac3cd58853bb58",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}