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: fuzz test not updated to use TypeMismatch #3768

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/functional/builtins/folding/test_bitwise.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest
from hypothesis import given, settings
from hypothesis import example, given, settings
from hypothesis import strategies as st

from tests.utils import parse_and_fold
from vyper.exceptions import InvalidType, OverflowException
from vyper.exceptions import OverflowException, TypeMismatch
from vyper.semantics.analysis.utils import validate_expected_type
from vyper.semantics.types.shortcuts import INT256_T, UINT256_T
from vyper.utils import unsigned_to_signed
Expand Down Expand Up @@ -66,9 +66,10 @@ def foo(a: uint256, b: uint256) -> uint256:


@pytest.mark.fuzzing
@settings(max_examples=50)
@settings(max_examples=51)
@pytest.mark.parametrize("op", ["<<", ">>"])
@given(a=st_sint256, b=st.integers(min_value=0, max_value=256))
@example(a=128, b=248) # throws TypeMismatch
def test_bitwise_shift_signed(get_contract, a, b, op):
source = f"""
@external
Expand All @@ -84,7 +85,7 @@ def foo(a: int256, b: uint256) -> int256:
validate_expected_type(new_node, INT256_T) # force bounds check
# compile time behavior does not match runtime behavior.
# compile-time will throw on OOB, runtime will wrap.
except (InvalidType, OverflowException):
except (TypeMismatch, OverflowException):
# check the wrapped value matches runtime
assert op == "<<"
assert contract.foo(a, b) == unsigned_to_signed((a << b) % (2**256), 256)
Expand Down
Loading