foundry
foundry copied to clipboard
feat(cheatcodes): extend usable range in `assertApproxEqRel`
Motivation
For large values, the current implementation of the cheatcode assertApproxEqRel overflows during calculation of the relative delta. However, using a larger type for this calculation allows to prevent overflows and use the full range of uint256.
Solution
The calculation was modified to use U512 for the calculation and only check that the final value for the delta fits inside a uint256 (a requirement of the error type).
PR Checklist
- [x] Added Tests
- [ ] Added Documentation
- [ ] Breaking changes
@zerosnacks let me add an overflow test quickly, I noticed it's missing
cc @klkvr would you mind double checking this proposed change