diff --git a/tests/hevm.py b/tests/hevm.py index 5348c4964f..0cb778fc91 100644 --- a/tests/hevm.py +++ b/tests/hevm.py @@ -32,11 +32,12 @@ def _prep_hevm_venom(venom_source_code, verbose=False): # small class to ensure correct function traversal order and help with # allocation class _FunctionVisitor: - num_calldataloads = 0 visited: set + num_calldataloads: int def __init__(self): self.visited = set() + self.num_calldataloads = 0 def _prep_hevm_venom_ctx(ctx, verbose=False): diff --git a/tests/unit/hevm/test_hevm_negative.py b/tests/unit/hevm/test_hevm_negative.py index f95793a5c6..734277d06b 100644 --- a/tests/unit/hevm/test_hevm_negative.py +++ b/tests/unit/hevm/test_hevm_negative.py @@ -1,6 +1,6 @@ import pytest -from tests.hevm import hevm_check_venom, hevm_raises +from tests.hevm import _prep_hevm_venom, hevm_check_venom, hevm_raises """ Test that the hevm harness can actually detect faults, @@ -11,6 +11,41 @@ pytestmark = pytest.mark.hevm +def test_hevm_source_limit(): + # 8 symbolic sources should work (hevm limit: 256 bytes of calldata) + code8 = """ + main: + %1 = source + %2 = source + %3 = source + %4 = source + %5 = source + %6 = source + %7 = source + %8 = source + sink %1 + """ + result = _prep_hevm_venom(code8) + assert isinstance(result, str) + + # 9 sources should fail the harness limit assertion + code9 = """ + main: + %1 = source + %2 = source + %3 = source + %4 = source + %5 = source + %6 = source + %7 = source + %8 = source + %9 = source + sink %1 + """ + with pytest.raises(AssertionError): + _prep_hevm_venom(code9) + + def test_hevm_simple(): code1 = """ main: