Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ spec-tools *args: (_tmp "spec-tools")
uv run pytest \
-n {{ xdist_workers }} \
--basetemp="{{ output_dir }}/spec-tools/tmp" \
--ignore=tests/evm_tools/test_count_opcodes.py \
"$@" \
tests/evm_tools

Expand Down
30 changes: 13 additions & 17 deletions tests/evm_tools/test_count_opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import json
from io import StringIO
from pathlib import Path
from typing import Callable

import pytest

Expand All @@ -16,25 +15,27 @@

parser = create_parser()

# Fixture 3 is the only client_clis alloc with code, so the only one
# that runs opcodes.
FIXTURE = Path(__file__).parents[2] / (
"packages/testing/src/execution_testing/client_clis/tests/fixtures/3"
)


@pytest.mark.evm_tools
def test_count_opcodes(root_relative: Callable[[str | Path], Path]) -> None:
def test_count_opcodes() -> None:
"""Test counting opcodes in a transaction execution using the T8N tool."""
base_path = root_relative(
"fixtures/evm_tools_testdata/t8n/fixtures/testdata/2"
)

options = parser.parse_args(
[
"t8n",
f"--input.env={base_path / 'env.json'}",
f"--input.alloc={base_path / 'alloc.json'}",
f"--input.txs={base_path / 'txs.json'}",
f"--input.env={FIXTURE / 'env.json'}",
f"--input.alloc={FIXTURE / 'alloc.json'}",
f"--input.txs={FIXTURE / 'txs.json'}",
"--output.result=stdout",
"--output.body=stdout",
"--output.alloc=stdout",
"--opcode.count=stdout",
"--state-test",
"--state.fork=Frontier",
]
)

Expand All @@ -47,10 +48,5 @@ def test_count_opcodes(root_relative: Callable[[str | Path], Path]) -> None:

results = json.loads(out_file.getvalue())

assert results["opcodeCount"] == {
"PUSH1": 5,
"MSTORE8": 1,
"CREATE": 1,
"ADD": 1,
"SELFDESTRUCT": 1,
}
# 0x600140 is PUSH1 then BLOCKHASH.
assert results["opcodeCount"] == {"PUSH1": 1, "BLOCKHASH": 1}