test: Convert amounts in testmempoolaccept test from float to decimal #20011

issue MarcoFalke opened this issue on September 25, 2020
  1. MarcoFalke commented at 7:03 AM on September 25, 2020: member

    Float should not be used for currency amounts (not even in tests). Thus float should be converted to use decimal. See also #19940#pullrequestreview-491979459

    Useful skills:

    Python 3

    Want to work on this issue?

    For guidance on contributing, please read CONTRIBUTING.md before opening your pull request.

  2. MarcoFalke added the label good first issue on Sep 25, 2020
  3. ghost commented at 12:43 PM on September 25, 2020: none

    This looks easy. Makes sense, decimal should be used for amount in bitcoin core for accuracy.

    Read the things mentioned in CONTRIBUTING.md

    Want to confirm if this is one of the changes we are trying to make?

    https://github.com/bitcoin/bitcoin/blob/ffaac6e6142a1cf61e8e12d7fc406fcb02300144/test/functional/wallet_send.py#L138

    assert_equal(from_balance_before - from_wallet.getbalance(), Decimal amount)
    
  4. hmrawal commented at 4:39 AM on September 26, 2020: none

    I would like to do this one as this will be my first contribution. I see the status as open but the code already has Decimal implemented. Could you please update on this ?

  5. n-moria12 commented at 5:32 AM on September 29, 2020: none

    import decimal assert_equal(from_balance_before - from_wallet.getbalance(), decimal.Decimal(amount))

    is this correct?

  6. MarcoFalke commented at 8:44 AM on September 29, 2020: member

    Converting a float to decimal where it is used doesn't help. It needs to be converted where it is defined, so that all calculations are done as decimal

  7. n-moria12 commented at 5:48 PM on September 29, 2020: none

    okay

  8. unknown cross-referenced this on Sep 29, 2020 from issue test: Convert amounts from float to decimal by ghost
  9. MarcoFalke closed this on Oct 22, 2020

  10. sidhujag referenced this in commit 1288257bea on Oct 22, 2020
  11. bitcoin locked this on Feb 15, 2022
  12. willcl-ark referenced this in commit 1048e494da on Nov 7, 2022
  13. vijaydasmp referenced this in commit 278bbc6972 on Jul 17, 2023
  14. vijaydasmp referenced this in commit 07c6897cae on Jul 18, 2023
  15. vijaydasmp referenced this in commit 7319fe3dd2 on Jul 20, 2023
  16. vijaydasmp referenced this in commit f22f56ed10 on Jul 21, 2023
  17. PastaPastaPasta referenced this in commit 945aca8b01 on Jul 21, 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-05-19 06:53 UTC