Skip to content

Commit

Permalink
handle failures when --optimize is set to none
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jan 14, 2025
1 parent fe1e9fd commit 4eb8332
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion tests/functional/builtins/codegen/test_ecrecover.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from eth_account import Account
from eth_account._utils.signing import to_bytes32

from tests.evm_backends.base_env import EvmError
from tests.utils import ZERO_ADDRESS


Expand Down Expand Up @@ -106,7 +107,7 @@ def do_ecrecover(hash: bytes32, v: uint256, r:uint256, s:uint256) -> address:
assert c.do_ecrecover(h, v, r, s) == local_account.address
gas_used = env.last_result.gas_used

with tx_failed():
with tx_failed(EvmError):
# provide enough spare gas for the top-level call to not oog but
# not enough for ecrecover to succeed
c.do_ecrecover(h, v, r, s, gas=gas_used - 1)
11 changes: 9 additions & 2 deletions tests/functional/codegen/types/test_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from tests.evm_backends.base_env import EvmError
from tests.utils import decimal_to_int
from vyper.compiler.settings import OptimizationLevel
from vyper.exceptions import ArrayIndexException, OverflowException, TypeMismatch


Expand Down Expand Up @@ -851,7 +852,7 @@ def foo() -> {return_type}:
assert_compile_failed(lambda: get_contract(code), TypeMismatch)


def test_array_copy_oog(env, get_contract, tx_failed):
def test_array_copy_oog(env, get_contract, tx_failed, optimize, request):
# GHSA-vgf2-gvx8-xwc3
code = """
@internal
Expand All @@ -864,6 +865,9 @@ def foo(x: uint256[3000]) -> uint256:
s: uint256[3000] = self.bar(x)
return s[0]
"""
if optimize == OptimizationLevel.NONE:
# fails in get_contract due to code too large
request.node.add_marker(pytest.mark.xfail(strict=True))

c = get_contract(code)
array = [2] * 3000
Expand All @@ -873,7 +877,7 @@ def foo(x: uint256[3000]) -> uint256:
c.foo(array, gas=gas_used - 1)


def test_array_copy_oog2(env, get_contract, tx_failed):
def test_array_copy_oog2(env, get_contract, tx_failed, optimize, request):
# GHSA-vgf2-gvx8-xwc3
code = """
@external
Expand All @@ -882,6 +886,9 @@ def foo(x: uint256[2500]) -> uint256:
t: uint256[2500] = s
return t[0]
"""
if optimize == OptimizationLevel.NONE:
# fails in get_contract due to code too large
request.node.add_marker(pytest.mark.xfail(strict=True))

c = get_contract(code)
array = [2] * 2500
Expand Down

0 comments on commit 4eb8332

Please sign in to comment.