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

cbdb891de2 test: Wait for txospender index to be synced in rpc_gettxspendingprevout (Ava Chow)
2db5c049bb 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 cbdb891de2
  andrewtoth:
    ACK cbdb891de2
  sedited:
    ACK cbdb891de2
  rkrux:
    crACK cbdb891de2

Tree-SHA512: ba1ab6216ac3b647a5f9e20f4899e51e643bf20829e698aa63c127c88ed4e33afa222bebeae1210fc869c46288e99c0b344330197913e244ffe1a6aca943568d
This commit is contained in:
merge-script
2026-03-06 10:30:45 +00:00

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: