Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix[test]: fix a bad bound in decimal fuzzing #3909

Merged
merged 9 commits into from
Apr 4, 2024

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Apr 3, 2024

fix a fuzz test, fix #2241, improve boundary conditions for some decimal fuzz tests.

What I did

How I did it

How to verify it

Commit message

the decimal fuzz test `is_valid` condition was based on an ancient
version of decimals which had bounds at `-2**127` and `2**127`. update
the condition to be compatible with the latest version of `decimal`.

also increase the range of decimals produced by the decimal fuzzing
strategy, so that the fuzzer finds overflow issues faster.

an additional issue was found in the fuzz tests, which is that some
decimal operations panic with `decimal.InvalidOperation` instead of a
proper exception. this is a known bug, see GH #2241. this fixes the
issue by catching the exception and raising an `OverflowException`.

misc/refactor:
- refactor several uses of quantize into a utility function

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

the decimal fuzz test `is_valid` condition was based on an ancient
version of decimals which had bounds at -2**127 and 2**127. update the
condition to be compatible with the latest version of Decimal.

also increase the range of decimals produced by the decimal fuzzing
strategy, so that the fuzzer finds overflow issues faster.
some OOB things do not get caught until analysis, so run the analyser.
@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.93%. Comparing base (dc62e7a) to head (9cb29e2).

❗ Current head 9cb29e2 differs from pull request most recent head bb95d04. Consider uploading reports for the commit bb95d04 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3909      +/-   ##
==========================================
- Coverage   90.93%   88.93%   -2.01%     
==========================================
  Files          95       95              
  Lines       14388    14391       +3     
  Branches     3186     3186              
==========================================
- Hits        13084    12798     -286     
- Misses        904     1133     +229     
- Partials      400      460      +60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-cooper charles-cooper enabled auto-merge (squash) April 4, 2024 15:41
@charles-cooper charles-cooper merged commit ee11e3d into vyperlang:master Apr 4, 2024
151 checks passed
electriclilies pushed a commit to electriclilies/vyper that referenced this pull request Apr 27, 2024
the decimal fuzz test `is_valid` condition was based on an ancient
version of decimals which had bounds at `-2**127` and `2**127`. update
the condition to be compatible with the latest version of `decimal`.

also increase the range of decimals produced by the decimal fuzzing
strategy, so that the fuzzer finds overflow issues faster.

an additional issue was found in the fuzz tests, which is that some
decimal operations panic with `decimal.InvalidOperation` instead of a
proper exception. this is a known bug, see GH vyperlang#2241. this fixes the
issue by catching the exception and raising an `OverflowException`.

misc/refactor:
- refactor several uses of quantize into a utility function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python level vs. Vyper-level Type Errors for Improper Uses of decimal
3 participants