From a85d5d586a78d6c5a2ac88508f63850a2d59c8b3 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Mon, 19 Jun 2023 18:46:56 -0500 Subject: [PATCH] test: temp fix for test --- ape_solidity/compiler.py | 25 ++++++++----------------- setup.py | 1 + tests/test_compiler.py | 18 ++++++++++++++---- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/ape_solidity/compiler.py b/ape_solidity/compiler.py index 5b47f99..bceaeeb 100644 --- a/ape_solidity/compiler.py +++ b/ape_solidity/compiler.py @@ -670,26 +670,17 @@ def _get_best_version(self, path: Path, source_by_pragma_spec: Dict) -> Version: def enrich_error(self, err: ContractLogicError) -> ContractLogicError: if not is_0x_prefixed(err.revert_message): + # Nothing to do. return err if panic_cls := _get_sol_panic(err.revert_message): - # Is from a Solidity panic code, like a builtin Solidity revert. - - if self._ape_version <= Version("0.6.10"): - return panic_cls( - contract_address=err.contract_address, - trace=err.trace, - txn=err.txn, - ) - else: - # TODO: Bump to next ape version and remove conditional. - return panic_cls( - base_err=err.base_err, - contract_address=err.contract_address, - source_traceback=err.source_traceback, - trace=err.trace, - txn=err.txn, - ) + return panic_cls( + base_err=err.base_err, + contract_address=err.contract_address, + source_traceback=err.source_traceback, + trace=err.trace, + txn=err.txn, + ) # Check for ErrorABI. bytes_message = HexBytes(err.revert_message) diff --git a/setup.py b/setup.py index 78b2476..93945a9 100644 --- a/setup.py +++ b/setup.py @@ -71,6 +71,7 @@ "packaging", # Use the version ape requires "requests", "typing-extensions==4.5.0", # Can be removed onced pinned in Core. + "web3[tester]>=0.6.5,<0.7.0", # Can remove any version after eth-ape 0.6.11 ], python_requires=">=3.8,<4", extras_require=extras_require, diff --git a/tests/test_compiler.py b/tests/test_compiler.py index ca70577..144c8f0 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -9,6 +9,7 @@ from ape.exceptions import CompilerError from ethpm_types.ast import ASTClassification from semantic_version import Version # type: ignore +from web3.exceptions import ContractPanicError from ape_solidity import Extension from ape_solidity._utils import OUTPUT_SELECTION @@ -398,10 +399,19 @@ def test_enrich_error_when_custom(compiler, project, owner, not_owner, connectio def test_enrich_error_when_builtin(project, owner, connection): - contract = project.BuiltinErrorChecker.deploy(sender=owner) - - with pytest.raises(IndexOutOfBoundsError): - contract.checkIndexOutOfBounds(sender=owner) + # TODO: Any version after eth-ape 0.6.11, you can uncomment this and delete the rest. + # contract = project.BuiltinErrorChecker.deploy(sender=owner) + # with pytest.raises(IndexOutOfBoundsError): + # contract.checkIndexOutOfBounds(sender=owner) + + compiler = project.compiler_manager.solidity + base_err = ContractPanicError( + message="Panic error 0x32: Array index is out of bounds.", + data="0x4e487b710000000000000000000000000000000000000000000000000000000000000032", + ) + actual = compiler.enrich_error(base_err) + assert isinstance(actual, IndexOutOfBoundsError) + assert actual.base_err == base_err def test_ast(project, compiler):