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

cbdb891de23d98dae3cfb3c4d993d6111df0aaa4 test: Wait for txospender index to be synced in rpc_gettxspendingprevout (Ava Chow)
2db5c049bb3cf9a323c100ce9d4957a937c01624 test: Sync mempools after tx creation in rpc_gettxspendingprevout (Ava Chow)

Pull request description:

  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:

  ```
  diff --git a/src/index/txospenderindex.cpp b/src/index/txospenderindex.cpp
  index d451bb1e0a4..e786f05a98c 100644
  --- a/src/index/txospenderindex.cpp
  +++ b/src/index/txospenderindex.cpp
  @@ -129,6 +129,7 @@ static std::vector<std::pair<COutPoint, CDiskTxPos>> BuildSpenderPositions(const

   bool TxoSpenderIndex::CustomAppend(const interfaces::BlockInfo& block)
   {
  +    UninterruptibleSleep(100ms);
       WriteSpenderInfos(BuildSpenderPositions(block));
       return true;
   }
  ```

  Fixes #34735

ACKs for top commit:
  furszy:
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  andrewtoth:
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  sedited:
    ACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4
  rkrux:
    crACK cbdb891de23d98dae3cfb3c4d993d6111df0aaa4

Tree-SHA512: ba1ab6216ac3b647a5f9e20f4899e51e643bf20829e698aa63c127c88ed4e33afa222bebeae1210fc869c46288e99c0b344330197913e244ffe1a6aca943568d
This commit is contained in:
merge-script 2026-03-06 10:30:45 +00:00
commit d97df29d5d
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -76,6 +76,9 @@ class GetTxSpendingPrevoutTest(BitcoinTestFramework):
txs = [txA, txB, txC, txD, txE, txF, txG, txH]
txidA, txidB, txidC, txidD, txidE, txidF, txidG, txidH = [tx["txid"] for tx in txs]
self.sync_mempools()
self.wait_until(lambda: node0.getindexinfo()["txospenderindex"]["synced"])
self.wait_until(lambda: node1.getindexinfo()["txospenderindex"]["synced"])
mempool = node0.getrawmempool()
assert_equal(len(mempool), 8)
for tx in txs: