fix: correct signed relative approximate assertions - #1166
Open
DicksonWu654 wants to merge 3 commits into
Open
Conversation
DicksonWu654
marked this pull request as ready for review
September 1, 2026 02:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
Both overloads previously shared a dispatcher that decoded a and b with #asWord. For the signed overload, negative int256 values therefore entered relative-error arithmetic as unsigned two-complement words. For example, 4 and -2 with a 1e18 tolerance could incorrectly pass.
The signed selector now uses Bytes2Int(..., BE, Signed) for a and b; maxPercentDelta remains an unsigned word. The common unbounded-Int relative-error rules continue to handle zero and int256 edge values without overflow. The signed message overload receives the same operand correction, without changing its separate string decoding or percentage formatting behavior.
Regression coverage
The existing passing opposite-sign unit fixture is enabled and exercises both the message and no-message signed overloads in both operand orders under the same tolerance. The already-active same-sign signed fixture remains a positive control. Exact revert-message cases remain skipped because they also depend on pre-existing error-string offset decoding and percentage formatting behavior outside this fix.
Testing
Tests were not run locally under the review constraint. The focused passing end-to-end fixture is enabled for upstream CI.