diff --git a/boa/environment.py b/boa/environment.py index 4c11e40c..62e76def 100644 --- a/boa/environment.py +++ b/boa/environment.py @@ -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( diff --git a/tests/unitary/test_coverage.py b/tests/unitary/test_coverage.py new file mode 100644 index 00000000..4f49a605 --- /dev/null +++ b/tests/unitary/test_coverage.py @@ -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) +