Closed sevastos closed 10 years ago
Good catch! This needs to get fixed.
I think resource-wallet
might also need an update as well?
see:
If you need an easy CouchDB setup you should be able to spin up a free instance instantly at http://www.iriscouch.com/
In order to create a unit test for the deposits
process I believe we'll need to create a mock for bitcoind?
Sure. Indeed resource-wallet
has similar issue bigcompany/resource-wallet#1. Also, its tests are currently breaking due to the 'any' data-type from mschema's pending of release 0.5.2.
I've published new mschema
v0.5.2
with any types, that should resolve that issue.
A case of such precision loss occurs due to binary floating point rounding. In our case an example case is when a user's bitcoin balance has 0.059 or 0.05900001 BTC or similar, then the deduction of 0.0001 BTC fee happens which results to totals of 0.058899999999999994 and 0.058900009999999996 accordingly.
In order to solve this and be able to do precise calculations with a lot of decimals, I added a new NPM package: bignumber.js, let me know if you prefer something else.
About the test, I haven't managed to get couchdb running and couldn't figure out a quick way to have a unit test for this case with the structure of lib/deposits/index.js, although I did a dirty refactoring locally to test it. If you have any idea on making the test, let me know and I will prep the test.
-Sev