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

issue MarcoFalke openend 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

    0assert_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. MarcoFalke closed this on Oct 22, 2020

  9. sidhujag referenced this in commit 1288257bea on Oct 22, 2020
  10. DrahtBot locked this on Feb 15, 2022
  11. willcl-ark referenced this in commit 1048e494da on Nov 7, 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: 2024-09-29 01:12 UTC

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