-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Description
Most of the values obtained interacting with web3 are bignums, for example the web3.eth.getBalance return value. In most of the assertions throughout the tests we compare them with JavaScript numbers. This coerces them into numbers and possibly introduces numerical errors. (Because JavaScript's native numbers are floating point, and e.g. 1000000000000000000 is indistinguishable from 1000000000000000001.)
I find it unlikely that this is causing false positives, but it should be fixed nevertheless. The numbers we work with in Ethereum can be pretty big and prone to this kind of error. For example the number shown in the previous paragraph is equivalent to 1 ether.
Apart from that, we should probably establish some convention to avoid this problem in the future, and document it in the contribution guidelines. I think it might be good to wrap assert.equal, etc., to treat bignums specially.
- Establish how to deal with this. Possibly defining some helper functions.
- Find all coercions to number (implicit or explicit) and fix them.
- Add a section in CONTRIBUTING.md.