From 4eb8332638345b7e104d32383fe3cf1aeb0f71d0 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Tue, 14 Jan 2025 12:25:15 -0500 Subject: [PATCH] handle failures when --optimize is set to none --- tests/functional/builtins/codegen/test_ecrecover.py | 3 ++- tests/functional/codegen/types/test_lists.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/functional/builtins/codegen/test_ecrecover.py b/tests/functional/builtins/codegen/test_ecrecover.py index 45dee8665b..d50ea91bcc 100644 --- a/tests/functional/builtins/codegen/test_ecrecover.py +++ b/tests/functional/builtins/codegen/test_ecrecover.py @@ -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 @@ -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) diff --git a/tests/functional/codegen/types/test_lists.py b/tests/functional/codegen/types/test_lists.py index eba589bc01..d54ff36b4f 100644 --- a/tests/functional/codegen/types/test_lists.py +++ b/tests/functional/codegen/types/test_lists.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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