test: Fix syncwithvalidationinterfacequeue calls #26091

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:2209-test-fix-🔻 changing 2 files +7 −3
  1. MarcoFalke commented at 2:42 PM on September 14, 2022: member

    Fixes #26071

  2. test/doc: Remove unused syncwithvalidationinterfacequeue
    See https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958562071
    
    Also fix doc typo from https://github.com/bitcoin/bitcoin/pull/25768#discussion_r958571943
    faa4916529
  3. fanquake added the label Tests on Sep 14, 2022
  4. test: Add missing syncwithvalidationinterfacequeue fa1ce96184
  5. MarcoFalke force-pushed on Sep 15, 2022
  6. MarcoFalke commented at 7:13 AM on September 15, 2022: member

    Diff to trigger the bug more often:

    diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
    index 613c5b65ef..17c135e7ea 100644
    --- a/src/validationinterface.cpp
    +++ b/src/validationinterface.cpp
    @@ -204,6 +204,7 @@ void CMainSignals::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockInd
     
     void CMainSignals::TransactionAddedToMempool(const CTransactionRef& tx, uint64_t mempool_sequence) {
         auto event = [tx, mempool_sequence, this] {
    +        UninterruptibleSleep(10ms);
             m_internals->Iterate([&](CValidationInterface& callbacks) { callbacks.TransactionAddedToMempool(tx, mempool_sequence); });
         };
         ENQUEUE_AND_LOG_EVENT(event, "%s: txid=%s wtxid=%s", __func__,
    diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py
    index 26df0841d8..0b8f4bf317 100755
    --- a/test/functional/wallet_resendwallettransactions.py
    +++ b/test/functional/wallet_resendwallettransactions.py
    @@ -86,6 +86,7 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
             child_txid = node.send(outputs=[{addr: 0.5}], options={"inputs": [{"txid":txid, "vout":0}]})["txid"]
             while True:
                 txids = node.listreceivedbyaddress(minconf=0, address_filter=addr)[0]["txids"]
    +            assert_equal(len(txids), 2)
                 if txids == [child_txid, txid]:
                     break
                 bumped = node.bumpfee(child_txid)
    
  7. in test/functional/wallet_resendwallettransactions.py:97 in fa1ce96184
      88 | @@ -89,6 +89,10 @@ def run_test(self):
      89 |              if txids == [child_txid, txid]:
      90 |                  break
      91 |              bumped = node.bumpfee(child_txid)
      92 | +            # The scheduler queue creates a copy of the added tx after
      93 | +            # send/bumpfee and re-adds it to the wallet (undoing the next
      94 | +            # removeprunedfunds). So empty the scheduler queue:
      95 | +            node.syncwithvalidationinterfacequeue()
      96 |              node.removeprunedfunds(child_txid)
      97 |              child_txid = bumped["txid"]
    


    glozow commented at 10:46 AM on September 15, 2022:

    Note to self/reviewer, I think this is why this fix works

    Without this, the ordering may be:

    1. child1 is created. Added(child1) event is added to queue
    2. child2 is created using bumpfee. Removed(child1) and Added(child2) events added to queue
    3. removeprunedfunds(child1) deletes child1 from wallet
    4. wallet.transactionAddedToMempool(child1) actually executes, re-adding child1 to wallet. bug.

    And now the ordering must be:

    1. child1 is created. Added(child1) event is added to queue
    2. wallet.transactionAddedToMempool(child1) executes
    3. child2 is created using bumpfee. Removed(child1) and Added(child2) events added to queue
    4. wallet.transactionAddedToMempool(child2) executes, wallet.transactionRemovedFromMempool(child1) executes.
    5. removeprunedfunds(child1) deletes child1 from wallet
  8. glozow commented at 10:51 AM on September 15, 2022: member

    ACK fa1ce96184a1815f453e64e14d77cb0025800be9

  9. w0xlt approved
  10. w0xlt commented at 12:34 PM on September 15, 2022: contributor
  11. fanquake added this to the milestone 24.0 on Sep 15, 2022
  12. fanquake requested review from achow101 on Sep 15, 2022
  13. achow101 commented at 5:16 PM on September 15, 2022: member

    ACK fa1ce96184a1815f453e64e14d77cb0025800be9

  14. achow101 merged this on Sep 15, 2022
  15. achow101 closed this on Sep 15, 2022

  16. MarcoFalke deleted the branch on Sep 15, 2022
  17. sidhujag referenced this in commit d0a9bea5af on Sep 15, 2022
  18. bitcoin locked this on Sep 15, 2023

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-04-17 06:13 UTC

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