test: Sync mempools and wait for txospender index to be synced in rpc_gettxspendingprevout #34747

pull achow101 wants to merge 2 commits into bitcoin:master from achow101:txospenderindex-test-wait-index-synced changing 1 files +3 −0
  1. achow101 commented at 7:23 pm on March 5, 2026: member

    On slower runs, the txospender index may not be synced yet when the tests of its behavior begin, causing intermittent failures. Wait for them to be synced before starting the tests.

    The tests also query mempool txs from other nodes, make sure mempools are synced before doing so.

    The first commit with the following diff reproduces #34735:

     0diff --git a/src/index/txospenderindex.cpp b/src/index/txospenderindex.cpp
     1index d451bb1e0a4..e786f05a98c 100644
     2--- a/src/index/txospenderindex.cpp
     3+++ b/src/index/txospenderindex.cpp
     4@@ -129,6 +129,7 @@ static std::vector<std::pair<COutPoint, CDiskTxPos>> BuildSpenderPositions(const
     5 
     6 bool TxoSpenderIndex::CustomAppend(const interfaces::BlockInfo& block)
     7 {
     8+    UninterruptibleSleep(100ms);
     9     WriteSpenderInfos(BuildSpenderPositions(block));
    10     return true;
    11 }
    

    Fixes #34735

  2. test: Sync mempools after tx creation in rpc_gettxspendingprevout
    The test will query information from the other nodes about mempool txs,
    ensure that the txs are in their mempools beforehand.
    2db5c049bb
  3. test: Wait for txospender index to be synced in rpc_gettxspendingprevout
    Each node's txospender index needs to catch up with the existing chain
    before the tests will work.
    cbdb891de2
  4. achow101 added this to the milestone 31.0 on Mar 5, 2026
  5. DrahtBot added the label Tests on Mar 5, 2026
  6. DrahtBot commented at 7:23 pm on March 5, 2026: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK furszy, andrewtoth, sedited, rkrux
    Concept ACK Bortlesboat

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  7. in test/functional/rpc_gettxspendingprevout.py:81 in cbdb891de2
    76@@ -77,6 +77,8 @@ def create_tx(**kwargs):
    77         txidA, txidB, txidC, txidD, txidE, txidF, txidG, txidH = [tx["txid"] for tx in txs]
    78 
    79         self.sync_mempools()
    80+        self.wait_until(lambda: node0.getindexinfo()["txospenderindex"]["synced"])
    81+        self.wait_until(lambda: node1.getindexinfo()["txospenderindex"]["synced"])
    


    furszy commented at 7:35 pm on March 5, 2026:

    You know for-loops don’t bite, right?

    0        for node in [node0, node1]:
    1            self.wait_until(lambda: node.getindexinfo()["txospenderindex"]["synced"])
    

    achow101 commented at 8:28 pm on March 5, 2026:
    If I retouch
  8. furszy commented at 7:35 pm on March 5, 2026: member
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  9. andrewtoth approved
  10. andrewtoth commented at 7:44 pm on March 5, 2026: contributor

    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4

    Applied that patch and verified rpc_gettxspendingprevout.py passes on this branch, and fails on master.

    Bottom of PR description should be updated:

    Fixes #34753

    should be #34735.

  11. sedited approved
  12. sedited commented at 8:18 pm on March 5, 2026: contributor
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  13. furszy commented at 9:08 pm on March 5, 2026: member
    This pushed me towards #34748. Hope it makes someone else’s life easier in the future.
  14. Bortlesboat commented at 5:44 am on March 6, 2026: none
    ACK
  15. rkrux approved
  16. rkrux commented at 6:32 am on March 6, 2026: contributor
    crACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  17. fanquake merged this on Mar 6, 2026
  18. fanquake closed this on Mar 6, 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-03-09 12:13 UTC

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