test: wallet_listtransactions improvements (speedup, cleanup, logging) #22423

pull theStack wants to merge 3 commits into bitcoin:master from theStack:202106-test-improve-wallet_listtransactions_test changing 2 files +22 −17
  1. theStack commented at 6:45 PM on July 10, 2021: member

    This PR improves the test wallet_listtransactions.py in three ways:

    • speeds up runtime by a factor of 2-3x by using the good ol' immediate tx relay trick (-whitelist=noban@127.0.0.1)
    • removes unneeded/redundant code
    • adds log messages, mostly by turning comments into self.log.info(...) calls
  2. DrahtBot added the label Tests on Jul 10, 2021
  3. DrahtBot commented at 8:48 PM on July 10, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. jonatack commented at 8:49 AM on July 15, 2021: member

    ACK c0abfa2d11a3ef847c68ef1a88bb3aa63d6fb7b2 modulo updating the positions of wallet_listtransactions.py --legacy-wallet and wallet_listtransactions.py --descriptors in the test runner from 2m to under 30s (per my testing, the run time drops from ~1m to ~10-15s).

    <details><summary>Some quick suggestions for your consideration in the last commit</summary><p>

    --- a/test/functional/wallet_listtransactions.py
    +++ b/test/functional/wallet_listtransactions.py
    @@ -105,19 +105,20 @@ class ListTransactionsTest(BitcoinTestFramework):
     
             self.run_rbf_opt_in_test()
     
    -    # Check that the opt-in-rbf flag works properly, for sent and received
    -    # transactions.
    +
         def run_rbf_opt_in_test(self):
    -        # Check whether a transaction signals opt-in RBF itself
    +        """Test the opt-in-rbf flag for sent and received transactions."""
    +
             def is_opt_in(node, txid):
    +            """Check whether a transaction signals opt-in RBF itself."""
                 rawtx = node.getrawtransaction(txid, 1)
                 for x in rawtx["vin"]:
                     if x["sequence"] < 0xfffffffe:
                         return True
                 return False
     
    -        # Find an unconfirmed output matching a certain txid
             def get_unconfirmed_utxo_entry(node, txid_to_match):
    +            """Find an unconfirmed output matching a certain txid."""
                 utxo = node.listunspent(0, 0)
                 for i in utxo:
                     if i["txid"] == txid_to_match:
    @@ -125,7 +126,7 @@ class ListTransactionsTest(BitcoinTestFramework):
                 return None
     
             self.log.info("Test txs w/o opt-in RBF (bip125-replaceable=no)")
    -        # Chain a few transactions that don't opt-in.
    +        # Chain a few transactions that don't opt in.
             txid_1 = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1)
             assert not is_opt_in(self.nodes[0], txid_1)
    
    @@ -205,5 +205,6 @@ class ListTransactionsTest(BitcoinTestFramework):
             assert_equal(self.nodes[0].gettransaction(txid_3b)["bip125-replaceable"], "no")
             assert_equal(self.nodes[0].gettransaction(txid_4)["bip125-replaceable"], "unknown")
     
    +
     if __name__ == '__main__':
         ListTransactionsTest().main()
    

    </p></details>

  5. theStack force-pushed on Jul 15, 2021
  6. test: speedup wallet_listtransactions by whitelisting peers (immediate tx relay)
    By whitelisting the peers via -whitelist, the inventory is transmissioned
    immediately rather than on average every 5 seconds, speeding up the test by at
    least a factor of two:
    
    before:
    $ time ./wallet_listtransactions.py
    ...
    0m40.25s real     0m01.74s user     0m01.70s system
    
    with this PR:
    $ time ./wallet_listtransactions.py
    ...
    0m14.93s real     0m01.68s user     0m01.87s system
    
    This commit also moves the wallet_listtransactions tests into the < 30s group.
    fb6c6a7938
  7. test: remove unneeded/redundant code in wallet_listtransactions
    -> remove unneeded get-out-of IBD generate()
    (The test framework already sets up the nodes to be out of IBD
     in setup_nodes(), if setup_clean_chain is not set to True)
    
    -> remove duplicate code line assigning an utxo
    47915b1187
  8. test: add logging to wallet_listtransactions
    Co-authored-by: Jon Atack <jon@atack.com>
    a006d7d730
  9. theStack force-pushed on Jul 15, 2021
  10. theStack commented at 11:23 PM on July 15, 2021: member

    @jonatack: Thanks for your review!

    [...] modulo updating the positions of wallet_listtransactions.py --legacy-wallet and wallet_listtransactions.py --descriptors in the test runner from 2m to under 30s (per my testing, the run time drops from ~1m to ~10-15s).

    Good idea, done. Put that into the first commit, due to a conflict in test_runner.py I also had to rebase the PR branch.

    Some quick suggestions for your consideration in the last commit

    Nice, agree that this PR is also a good oportunity to change to docstrings. Took your suggestions and added you as co-author in the last commit.

  11. jonatack commented at 8:45 PM on July 16, 2021: member

    Thanks for updating!

    ACK a006d7d73019b8cf4d68626c019c3d69729dda69

  12. kristapsk approved
  13. kristapsk commented at 12:16 PM on July 20, 2021: contributor

    ACK a006d7d73019b8cf4d68626c019c3d69729dda69

  14. practicalswift commented at 8:06 PM on July 24, 2021: contributor

    Concept ACK

  15. MarcoFalke merged this on Jul 28, 2021
  16. MarcoFalke closed this on Jul 28, 2021

  17. sidhujag referenced this in commit 6e7e294724 on Jul 28, 2021
  18. theStack deleted the branch on Jul 31, 2021
  19. Fabcien referenced this in commit 0dfb5f4653 on Jan 21, 2022
  20. DrahtBot locked this on Aug 16, 2022

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-14 21:14 UTC

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