Skip to content

Commit

Permalink
fix RecursionError tracing child computations
Browse files Browse the repository at this point in the history
  • Loading branch information
cfcfs committed Feb 21, 2024
1 parent 50fdb2a commit eac4adb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
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)

0 comments on commit eac4adb

Please sign in to comment.