Skip to content

Commit 52140ef

Browse files
committed
feat(consume): allow geth to validate eof test vectors via direct
1 parent b19b4ca commit 52140ef

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/ethereum_clis/clis/geth.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
ExceptionMessage,
1616
TransactionException,
1717
)
18-
from ethereum_test_fixtures import BlockchainFixture, FixtureFormat, StateFixture
18+
from ethereum_test_fixtures import BlockchainFixture, EOFFixture, FixtureFormat, StateFixture
1919
from ethereum_test_forks import Fork
2020

2121
from ..ethereum_cli import EthereumCLI
@@ -246,7 +246,7 @@ def is_fork_supported(self, fork: Fork) -> bool:
246246
class GethFixtureConsumer(
247247
GethEvm,
248248
FixtureConsumerTool,
249-
fixture_formats=[StateFixture, BlockchainFixture],
249+
fixture_formats=[StateFixture, BlockchainFixture, EOFFixture],
250250
):
251251
"""Geth's implementation of the fixture consumer."""
252252

@@ -290,6 +290,38 @@ def consume_blockchain_test(
290290
f"Unexpected exit code:\n{' '.join(command)}\n\n Error:\n{result.stderr}"
291291
)
292292

293+
def consume_eof_test(
294+
self,
295+
fixture_path: Path,
296+
fixture_name: Optional[str] = None,
297+
debug_output_path: Optional[Path] = None,
298+
):
299+
"""Consume an EOF validation test (valid yes/no) without running any EOF code."""
300+
subcommand = "eofparse"
301+
global_options = []
302+
subcommand_options = ["--test"]
303+
if debug_output_path:
304+
global_options += ["--verbosity", "100"]
305+
# --trace does not exist for eofparse
306+
307+
command = (
308+
[str(self.binary)]
309+
+ global_options
310+
+ [subcommand]
311+
+ subcommand_options
312+
+ [str(fixture_path)]
313+
)
314+
315+
result = self._run_command(command)
316+
317+
if debug_output_path:
318+
self._consume_debug_dump(command, result, fixture_path, debug_output_path)
319+
320+
if result.returncode != 0:
321+
raise Exception(
322+
f"Unexpected exit code:\n{' '.join(command)}\n\n Error:\n{result.stderr}"
323+
)
324+
293325
@cache # noqa
294326
def consume_state_test_file(
295327
self,
@@ -385,6 +417,12 @@ def consume_fixture(
385417
fixture_name=fixture_name,
386418
debug_output_path=debug_output_path,
387419
)
420+
elif fixture_format == EOFFixture:
421+
self.consume_eof_test(
422+
fixture_path=fixture_path,
423+
fixture_name=fixture_name,
424+
debug_output_path=debug_output_path,
425+
)
388426
else:
389427
raise Exception(
390428
f"Fixture format {fixture_format.format_name} not supported by {self.binary}"

0 commit comments

Comments
 (0)