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

[pull] main from ApeWorX:main #265

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.8.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 7.1.0
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic]
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"hypothesis-jsonschema==0.19.0", # JSON Schema fuzzer extension
],
"lint": [
"black>=24.4.2,<25", # Auto-formatter and linter
"black>=24.8.0,<25", # Auto-formatter and linter
"mypy>=1.11.1,<2", # Static type analyzer
"types-PyYAML", # Needed due to mypy typeshed
"types-requests", # Needed due to mypy typeshed
Expand All @@ -30,7 +30,7 @@
"types-toml", # Needed due to mypy typeshed
"types-SQLAlchemy>=1.4.49", # Needed due to mypy typeshed
"types-python-dateutil", # Needed due to mypy typeshed
"flake8>=7.1.0,<8", # Style linter
"flake8>=7.1.1,<8", # Style linter
"flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code
"flake8-print>=4.0.1,<5", # Detect print statements left in code
"flake8-pydantic", # For detecting issues with Pydantic models
Expand Down
5 changes: 4 additions & 1 deletion src/ape_ethereum/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,10 @@ def try_get_revert_msg(c) -> Optional[str]:
return message

# Enrichment call-tree not available. Attempt looking in trace-frames.
return to_hex(self._revert_str_from_trace_frames)
if revert_str := self._revert_str_from_trace_frames:
return to_hex(revert_str)

return None

@cached_property
def _last_frame(self) -> Optional[dict]:
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ def validate_cwd(start_dir):
def project():
path = "tests/functional/data/contracts/ethereum/local"
with ape.project.temp_config(contracts_folder=path):
ape.project.manifest_path.unlink(missing_ok=True)
ape.project.clean()
yield ape.project
ape.project.manifest_path.unlink(missing_ok=True)
ape.project.clean()


@pytest.fixture(scope="session")
Expand Down
1 change: 1 addition & 0 deletions tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def project_with_dependency_config(project):
}
],
}
project.clean()
with project.isolate_in_tempdir(**dependencies_config) as tmp_project:
yield tmp_project

Expand Down
15 changes: 15 additions & 0 deletions tests/functional/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,21 @@ def test_revert_message_custom_error(simple_trace_cls, setup_custom_error):
assert trace.revert_message == expected


def test_revert_message_empty(owner):
tx = owner.transfer(owner, 0)
trace = TransactionTrace.model_validate({"transaction_hash": tx.txn_hash})

# Hack in criteria to cause it to look for a revert message more.
trace._enriched_calltree = {"failed": True}

# Only testing private member here because it was related to the bug.
assert trace._revert_str_from_trace_frames is None

# For failed transactions with no available revert message, it should NOT crash!
# (It's None because there is no revert message).
assert trace.revert_message is None


def test_enriched_calltree_adds_missing_gas(simple_trace_cls):
compute_gas = 1234
base_gas = 21_000
Expand Down
Loading