Skip to content

Commit

Permalink
fix[test]: fix a boundary case in decimal fuzzing (#3918)
Browse files Browse the repository at this point in the history
change to not test the boundary condition at all, but rely on whether
`ExprVisitor().visit()` throws an exception or not.
  • Loading branch information
charles-cooper authored Apr 9, 2024
1 parent 3ea2ae1 commit eb81c26
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/unit/ast/nodes/test_fold_binop_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def foo(a: decimal, b: decimal) -> decimal:
try:
vyper_ast = parse_and_fold(f"{left} {op} {right}")
expr = vyper_ast.body[0].value

# check invalid values
ExprVisitor().visit(expr, DecimalT())

new_node = expr.get_folded_value()
is_valid = True
except (OverflowException, ZeroDivisionException):
Expand Down Expand Up @@ -81,11 +84,13 @@ def foo({input_value}) -> decimal:
try:
vyper_ast = parse_and_fold(literal_op)
expr = vyper_ast.body[0].value

# check invalid intermediate values
ExprVisitor().visit(expr, DecimalT())

new_node = expr.get_folded_value()
expected = new_node.value
lo, hi = DecimalT().decimal_bounds
is_valid = lo <= expected < hi
is_valid = True
except (OverflowException, ZeroDivisionException):
# for overflow or division/modulus by 0, expect the contract call to revert
is_valid = False
Expand Down

0 comments on commit eb81c26

Please sign in to comment.