[tests] Add wallet_balance.py #14845

pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:balance_tests changing 3 files +134 −13
  1. jnewbery commented at 6:39 PM on November 29, 2018: member

    Adds a test specifically to test the wallet's getbalance and getunconfirmedbalance RPCs.

    wallet_basic.py is too large and should be broken down into more focused test cases.

    I wrote wallet_balance.py to test the changes in #14602. Offering as a PR in case people think it's more generally useful.

  2. fanquake added the label Tests on Nov 29, 2018
  3. promag commented at 12:02 AM on November 30, 2018: member

    more focused test cases

    :+1:

  4. Empact commented at 12:27 AM on November 30, 2018: member

    Concept ACK

  5. in test/functional/wallet_balance.py:2 in b31985d8c9 outdated
       0 | @@ -0,0 +1,133 @@
       1 | +#!/usr/bin/env python3
       2 | +# Copyright (c) 2014-2018 The Bitcoin Core developers
    


    kallewoof commented at 8:47 AM on November 30, 2018:

    2018? Or is this based on existing stuff?


    jnewbery commented at 3:28 PM on November 30, 2018:

    no, this should be 2018

  6. in test/functional/wallet_balance.py:78 in b31985d8c9 outdated
      73 | +        self.nodes[1].sendrawtransaction(txs[0]['hex'])  # sending on both nodes is faster than waiting for propogation
      74 | +
      75 | +        self.sync_all()
      76 | +        txs = self.create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), 60, [Decimal('0.01'), Decimal('0.02')])
      77 | +        self.nodes[1].sendrawtransaction(txs[0]['hex'])
      78 | +        self.nodes[0].sendrawtransaction(txs[0]['hex'])  # sending on both nodes is faster than waiting for propogation
    


    kallewoof commented at 8:50 AM on November 30, 2018:

    propagation


    jnewbery commented at 3:28 PM on November 30, 2018:

    fixed. Thanks

  7. in test/functional/wallet_balance.py:73 in b31985d8c9 outdated
      68 | +        assert_equal(self.nodes[0].getbalance(minconf=1), 50)
      69 | +
      70 | +        # Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0.
      71 | +        txs = self.create_transactions(self.nodes[0], self.nodes[1].getnewaddress(), 40, [Decimal('0.01')])
      72 | +        self.nodes[0].sendrawtransaction(txs[0]['hex'])
      73 | +        self.nodes[1].sendrawtransaction(txs[0]['hex'])  # sending on both nodes is faster than waiting for propogation
    


    kallewoof commented at 8:50 AM on November 30, 2018:

    propagation


    jnewbery commented at 3:28 PM on November 30, 2018:

    fixed. Thanks

  8. kallewoof commented at 8:54 AM on November 30, 2018: member

    utACK b31985d8c9a1cac749250a8f976fa6ccc2095b1e

    A little confused by "getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago". Isn't it supposed to ignore balance for UTXOs whose confirmations < minconf?

  9. in test/functional/wallet_balance.py:24 in b31985d8c9 outdated
      19 | +        self.setup_clean_chain = True
      20 | +
      21 | +    def skip_test_if_missing_module(self):
      22 | +        self.skip_if_no_wallet()
      23 | +
      24 | +    def create_transactions(self, node, address, amt, fees):
    


    practicalswift commented at 9:03 AM on November 30, 2018:

    create_transactions is not using self and could thus be a function instead of a method?


    jnewbery commented at 3:28 PM on November 30, 2018:

    Good point. Changed to a function.

  10. [tests] Add wallet_balance.py
    Adds a test specifically to test the wallet's getbalance and
    getunconfirmedbalance RPCs.
    c1825b9d39
  11. jnewbery force-pushed on Nov 30, 2018
  12. jnewbery commented at 3:34 PM on November 30, 2018: member

    Thanks for the review @kallewoof and @practicalswift !

    A little confused by "getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago". Isn't it supposed to ignore balance for UTXOs whose confirmations < minconf?

    Yes, there's currently a bug when getbalance is called with minconf=0, that it checks for UTXO creation, but not UTXO spending. That's fixed in this commit: https://github.com/bitcoin/bitcoin/pull/14602/commits/cfa948da1c5a283fe8f5a80cc0c0dda055408783, but there's more work to be done before that PR is ready for merge.

  13. MarcoFalke commented at 4:16 PM on November 30, 2018: member

    utACK c1825b9d398b31967887c459c0fad9cf56cf95c6 (Also checked that the test passes on 0.17, which qualifies it for backport)

  14. MarcoFalke referenced this in commit 81bd349c9c on Nov 30, 2018
  15. MarcoFalke merged this on Nov 30, 2018
  16. MarcoFalke closed this on Nov 30, 2018

  17. MarcoFalke referenced this in commit 67225e2fd7 on Nov 30, 2018
  18. jnewbery deleted the branch on Nov 30, 2018
  19. jnewbery commented at 4:40 PM on November 30, 2018: member

    Backported in #14852

  20. luke-jr referenced this in commit cd8dc4bf35 on Dec 21, 2018
  21. dartdart26 referenced this in commit 47569047ad on Dec 28, 2018
  22. dartdart26 referenced this in commit 365f1b3339 on Dec 28, 2018
  23. deadalnix referenced this in commit c2b6ca7130 on May 4, 2020
  24. ftrader referenced this in commit ffd3e982ba on Aug 17, 2020
  25. Munkybooty referenced this in commit 64654ce05d on Jul 30, 2021
  26. Munkybooty referenced this in commit 565ac46233 on Aug 17, 2021
  27. MarcoFalke locked this on Sep 8, 2021

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-13 15:15 UTC

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