From a24374b16b0d6c412795f2b499daf8761d7fdec1 Mon Sep 17 00:00:00 2001 From: antazoey Date: Fri, 25 Oct 2024 13:09:30 -0500 Subject: [PATCH] fix: use str type with bytes validator (#2340) --- src/ape_ethereum/trace.py | 3 ++- tests/functional/test_trace.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ape_ethereum/trace.py b/src/ape_ethereum/trace.py index 51e8cf3565..0812624f96 100644 --- a/src/ape_ethereum/trace.py +++ b/src/ape_ethereum/trace.py @@ -7,6 +7,7 @@ from functools import cached_property from typing import IO, Any, Optional, Union +from eth_pydantic_types import HexStr from eth_utils import is_0x_prefixed, to_hex from ethpm_types import ContractType, MethodABI from evm_trace import ( @@ -447,7 +448,7 @@ def _get_abi(self, call: dict) -> Optional[MethodABI]: class TransactionTrace(Trace): - transaction_hash: str + transaction_hash: HexStr debug_trace_transaction_parameters: dict = {"enableMemory": True} _frames: list[dict] = [] diff --git a/tests/functional/test_trace.py b/tests/functional/test_trace.py index d27c94d98d..f4c4428f5e 100644 --- a/tests/functional/test_trace.py +++ b/tests/functional/test_trace.py @@ -134,8 +134,9 @@ def test_get_gas_report_with_sub_calls(simple_trace_cls): assert len(actual) > 1 # Sub-contract calls! -def test_transaction_trace_create(vyper_contract_instance): - tx_hash = vyper_contract_instance.creation_metadata.txn_hash +@pytest.mark.parametrize("txn_hash_callback", (str, HexBytes)) +def test_transaction_trace_create(vyper_contract_instance, txn_hash_callback): + tx_hash = txn_hash_callback(vyper_contract_instance.creation_metadata.txn_hash) trace = TransactionTrace(transaction_hash=tx_hash) actual = f"{trace}" expected = r"VyperContract\.__new__\(num=0\) \[\d+ gas\]"