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

fix RecursionError tracing child computations #171

Merged
merged 1 commit into from
Feb 22, 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
2 changes: 1 addition & 1 deletion boa/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def _hook_trace_computation(self, computation, contract=None):
if child.msg.code_address == b"":
continue
child_contract = self._lookup_contract_fast(child.msg.code_address)
self._hook_trace_computation(computation, child_contract)
self._hook_trace_computation(child, child_contract)

# function to time travel
def time_travel(
Expand Down
40 changes: 40 additions & 0 deletions tests/unitary/test_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest
import boa


@pytest.fixture(scope="module")
def external_contract():
source_code = """
@external
@view
def foo(a: uint256) -> uint256:
return a * a
"""
return boa.loads(source_code, name="ExternalContract")


@pytest.fixture(scope="module")
def source_contract(external_contract):
source_code = """
interface Foo:
def foo(a: uint256) -> uint256: view

FOO: immutable(address)

@external
def __init__(_foo_address: address):
FOO = _foo_address

@external
@view
def bar(b: uint256) -> uint256:
c: uint256 = Foo(FOO).foo(b)
return c
"""
return boa.loads(source_code, external_contract.address, name="TestContract")


def test_sub_computations(source_contract):
boa.env._coverage_enabled = True
source_contract.bar(10)

Loading