test: fix confusing off-by-one nValue in feature_coinstatsindex.py #23037

pull theStack wants to merge 1 commits into bitcoin:master from theStack:202109-test-fix_namount_offbyone_in_coinstatsindex changing 1 files +6 −6
  1. theStack commented at 7:26 PM on September 19, 2021: member

    Due to evil floating-point arithmetic, the creation of one of the transaction outputs in feature_coinstatsindex.py leads to it's nValue being off by one satoshi: the Python expression int(21.99 * COIN) doesn't yield 2199000000 as expected, but 2198999999.

    This makes the test more confusing than necessary (w.r.t. the expected gettxoutsetinfo values), and could also cause problems if the value is ever changed. Fix by using a Decimal type for specifying the value in BTC, rather than using a bare floating-point.

  2. test: fix confusing off-by-one nValue in feature_coinstatsindex.py
    Due to evil floating-point arithmetic, the creation of one of the
    transaction outputs in feature_coinstatsindex.py leads to it's nValue
    being off by one satoshi: the Python expression `int(21.99 * COIN)`
    doesn't yield 2199000000 as expected, but 2198999999.
    
    This makes the test more confusing than necessary (w.r.t. the expected
    `gettxoutsetinfo` values), and could also cause problems if the value
    is ever changed. Fix by using a `Decimal` type for specifying the
    value in BTC, rather than using a bare floating-point.
    ebe49b5b7c
  3. DrahtBot added the label Tests on Sep 19, 2021
  4. MarcoFalke commented at 5:59 AM on September 20, 2021: member

    cr ACK ebe49b5b7cda0f9e8dc4bb4795da0ca44a97aa1d

  5. MarcoFalke merged this on Sep 20, 2021
  6. MarcoFalke closed this on Sep 20, 2021

  7. sidhujag referenced this in commit 2a7c46503c on Sep 20, 2021
  8. theStack deleted the branch on Sep 21, 2021
  9. DrahtBot locked this on Oct 30, 2022
Contributors
Labels

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

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