Skip to content

Commit

Permalink
test: tests are stupid
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jan 6, 2025
1 parent 027bcfd commit 2d5c1a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/ape_ethereum/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,7 @@ def _discover_calltrace_approach(self) -> CallTreeNode:
self._set_approach(approach)
return call

# Not sure this would happen, as the basic-approach should
# always work.
# Not sure this happens, as the basic-approach should always work.
reason_str = ", ".join(f"{k}={v}" for k, v in reason_map.items())
raise ProviderError(f"Unable to create CallTreeNode. Reason(s): {reason_str}")

Expand Down
18 changes: 12 additions & 6 deletions tests/functional/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,24 +239,30 @@ def side_effect(rpc, arguments):


def test_transaction_trace_provider_does_not_implement_client_version(
mocker, vyper_contract_instance, not_owner, networks
mocker, vyper_contract_instance, not_owner, networks, ethereum, chain
):
tx = vyper_contract_instance.setNumber(0, sender=not_owner, raise_on_revert=False)
mock_weird_node = mocker.MagicMock()
mock_weird_node.client_version.side_effect = AttributeError
provider = networks.provider
networks.active_provider = mock_weird_node
trace = TransactionTrace.model_validate(
mock_weird_node.network = ethereum.local

class HackyTransactionTrace(TransactionTrace):
def _discover_calltrace_approach(self) -> CallTreeNode:
# Not needed for test.
return None # type: ignore

trace = HackyTransactionTrace.model_validate(
{
"call_trace_approach": None,
"debug_trace_transaction_parameters": {"enableMemory": True},
"transaction_hash": tx.txn_hash,
"transaction": tx,
}
)
actual = trace.get_calltree()
provider = networks.provider
networks.active_provider = mock_weird_node
_ = trace.get_calltree()
networks.provider = provider
assert isinstance(actual, CallTreeNode)
assert trace.call_trace_approach is not TraceApproach.PARITY


Expand Down

0 comments on commit 2d5c1a1

Please sign in to comment.