From 9cdf52130e4e74485e1bf9f9580ce973005ac4e9 Mon Sep 17 00:00:00 2001 From: Felix H Date: Mon, 12 Jan 2026 10:50:01 +0000 Subject: [PATCH 1/8] implemented fselmo feedback + replaced deprecated with --- .../test_types/transaction_types.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index 0245581e62..667e26f25d 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -842,6 +842,37 @@ def signer_minimum_balance(self, *, fork: Fork) -> int: else: return gas_price * gas_limit + self.value + def _format_field_value(self, value: Any) -> str: + """ + Format a field value for string representation. + + Uses hex encoding for any value that supports it + (Address, Bytes, Hash, HexNumber, etc). + """ + if value is None: + return "None" + elif hasattr(value, "hex"): + return value.hex() + else: + return repr(value) + + def __repr__(self) -> str: + """ + Return string representation with hex-encoded values for + applicable fields. + """ + field_strs = [] + for field_name in self.__class__.model_fields: + value = getattr(self, field_name) + formatted_value = self._format_field_value(value) + field_strs.append(f"{field_name}={formatted_value}") + + return f"{self.__class__.__name__}({', '.join(field_strs)})" + + def __str__(self) -> str: + """Return the repr string representation.""" + return self.__repr__() + class NetworkWrappedTransaction(CamelModel, RLPSerializable): """ From 8cdad24c833153b28ba7716c2588513abba9ddb9 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 13 Jan 2026 10:45:09 +0100 Subject: [PATCH 2/8] fix(gentest): improve ruff error reporting with full diagnostic output Remove --quiet flag and include returncode, stdout, and stderr in error messages to enable diagnosis of formatting failures. --- .../execution_testing/cli/gentest/source_code_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/testing/src/execution_testing/cli/gentest/source_code_generator.py b/packages/testing/src/execution_testing/cli/gentest/source_code_generator.py index 7f316cbd08..ecbed9150e 100644 --- a/packages/testing/src/execution_testing/cli/gentest/source_code_generator.py +++ b/packages/testing/src/execution_testing/cli/gentest/source_code_generator.py @@ -89,7 +89,6 @@ def format_code(code: str) -> str: str(formatter_path), "format", str(input_file_path), - "--quiet", "--no-cache", "--config", str(config_path), @@ -100,7 +99,8 @@ def format_code(code: str) -> str: if result.returncode != 0: raise Exception( f"Error formatting code using formatter '{formatter_path}': " - f"{result.stderr}" + f"returncode={result.returncode}, stdout={result.stdout!r}, " + f"stderr={result.stderr!r}" ) # Return the formatted source code From 60f8958799af0a97f1cbe3a3fbd19c877f2c11e9 Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 13 Jan 2026 10:51:37 +0100 Subject: [PATCH 3/8] fix(test-types): ensure valid hex field values are returned Wrap hex values in quotes to produce valid Python string literals in Transaction.__repr__(). Previously, empty bytes (data=b"") would generate `data=0x` via Bytes(b"").hex() returning "0x", which is invalid Python syntax (needs at least one digit like 0x0). This caused ruff to fail when formatting generated test code. Now hex values are quoted strings (e.g., data="0x") which are always valid Python and accepted by the framework's type coercion. Co-authored-by: @fselmo --- .../src/execution_testing/test_types/transaction_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index 667e26f25d..41e8862b15 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -852,7 +852,7 @@ def _format_field_value(self, value: Any) -> str: if value is None: return "None" elif hasattr(value, "hex"): - return value.hex() + return f'"{value.hex()}"' else: return repr(value) From 6b1c69ba711dfaa60a793a849331a49df73e9e6b Mon Sep 17 00:00:00 2001 From: Felix H Date: Tue, 13 Jan 2026 11:43:38 +0000 Subject: [PATCH 4/8] show int and other numbers as decimal --- .../test_types/transaction_types.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index 41e8862b15..04ba8bc652 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -1,8 +1,10 @@ """Transaction-related types for Ethereum tests.""" from dataclasses import dataclass +import decimal from enum import IntEnum from functools import cached_property +import numbers from typing import Any, ClassVar, Dict, Generic, List, Literal, Self, Sequence import ethereum_rlp as eth_rlp @@ -851,10 +853,21 @@ def _format_field_value(self, value: Any) -> str: """ if value is None: return "None" - elif hasattr(value, "hex"): + + # fields like 'value' should be shown as decimal number + if isinstance(value, numbers.Number): + if isinstance(value, decimal.Decimal): + # Convert to string to avoid scientific notation (1E-9) + # while removing unnecessary trailing zeros (100.000000 -> 100) + return "{:f}".format(value).rstrip("0").rstrip(".") + + return str(value) + + # fields like 'to' should be shown as hex string + if hasattr(value, "hex") and callable(value.hex): return f'"{value.hex()}"' - else: - return repr(value) + + return repr(value) def __repr__(self) -> str: """ From 0c411a7e5c89644130877ce6ad74c154f806e0c9 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 13 Jan 2026 17:02:02 +0100 Subject: [PATCH 5/8] Update packages/testing/src/execution_testing/test_types/transaction_types.py Co-authored-by: danceratopz --- .../src/execution_testing/test_types/transaction_types.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index 04ba8bc652..f4b15c84cc 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -861,6 +861,10 @@ def _format_field_value(self, value: Any) -> str: # while removing unnecessary trailing zeros (100.000000 -> 100) return "{:f}".format(value).rstrip("0").rstrip(".") + # Force decimal representation for int subclasses like HexNumber + if isinstance(value, int): + return str(int(value)) + return str(value) # fields like 'to' should be shown as hex string From a0b898a34eff1180ccbfdb954467ba39b6deb23b Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 13 Jan 2026 17:02:10 +0100 Subject: [PATCH 6/8] Update packages/testing/src/execution_testing/test_types/transaction_types.py Co-authored-by: danceratopz --- .../src/execution_testing/test_types/transaction_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index f4b15c84cc..b85a47fb6c 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -848,8 +848,8 @@ def _format_field_value(self, value: Any) -> str: """ Format a field value for string representation. - Uses hex encoding for any value that supports it - (Address, Bytes, Hash, HexNumber, etc). + Uses decimal for numeric values (int, HexNumber, etc.) and + hex encoding for Address, Bytes, Hash, etc. """ if value is None: return "None" From 300b4b8a16006eef851712f0b6bc44ee8a8c92d1 Mon Sep 17 00:00:00 2001 From: felix Date: Tue, 13 Jan 2026 17:02:40 +0100 Subject: [PATCH 7/8] Update packages/testing/src/execution_testing/test_types/transaction_types.py Co-authored-by: danceratopz --- .../src/execution_testing/test_types/transaction_types.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index b85a47fb6c..4cfca88e87 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -856,11 +856,6 @@ def _format_field_value(self, value: Any) -> str: # fields like 'value' should be shown as decimal number if isinstance(value, numbers.Number): - if isinstance(value, decimal.Decimal): - # Convert to string to avoid scientific notation (1E-9) - # while removing unnecessary trailing zeros (100.000000 -> 100) - return "{:f}".format(value).rstrip("0").rstrip(".") - # Force decimal representation for int subclasses like HexNumber if isinstance(value, int): return str(int(value)) From 92b855caf1a51226e671b95e9510d45b86fa0b7e Mon Sep 17 00:00:00 2001 From: danceratopz Date: Tue, 13 Jan 2026 20:11:37 +0100 Subject: [PATCH 8/8] style(test-types): remove unused import, fix ruff --- .../src/execution_testing/test_types/transaction_types.py | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/testing/src/execution_testing/test_types/transaction_types.py b/packages/testing/src/execution_testing/test_types/transaction_types.py index 4cfca88e87..aa4ef542fb 100644 --- a/packages/testing/src/execution_testing/test_types/transaction_types.py +++ b/packages/testing/src/execution_testing/test_types/transaction_types.py @@ -1,7 +1,6 @@ """Transaction-related types for Ethereum tests.""" from dataclasses import dataclass -import decimal from enum import IntEnum from functools import cached_property import numbers