ethereum / ethereum/execution-specs

Create opcode test cases generator

Open
#1,574 1 comment 0 reactions 0 assignees View on GitHub
A-test-tests C-feat stale
Dominant language
Python
Stars
1.2k
Forks
505
Avg merge
2d 14h
Merged PRs (30d)
116

Description

For a future PR:

I think we can generalize these into a test generator:

Given (1) an Opcode, (2) a list of verification stack inputs/ouputs combinations, test the opcode in many different contexts and verify it works correctly, including Call-contexts, contract creation contexts, 7702 delegation context, etc.

Something like:
```python
def generate_context_tests_for_opcode(
opcode: Op,
inputs_outputs: List[Tuple[List[int], int]],
):
```
And then on a test file you can do:
```python
@generate_context_tests_for_opcode(
opcode=Op.CLZ,
inputs_outputs=[ ( [0x01], 0x01 ), ( [0xff], 256 - 8 ), ...
)
def test_clz_in_all_contexts(
...
```

_Originally posted by @marioevz in https://github.com/ethereum/execution-spec-tests/pull/1829#discussion_r2231560633_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.