You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(checklists): add EIPChecklist enum to specify EIP checklist items (#1718)
* fix: move unit test
* Create Enums - Incomplete/broken attempt
* fix(filler/checklist): Template copying bug
* fix: EIPChecklist usage
* docs: Update usage
* refactor(eip_checklist): Remove new_* from all IDs
* fix: tox (minus spellcheck)
* fix: typing
* fix(docs,checklists): Rename section to be more descriptive
* docs: remove references to string EIP checklist notation
* docs: backtick `EIPChecklist` instances
* docs: update changelog
* docs: fix title
* fix(checklists): allow ommission of parentheses in checklist markers
* style(checklists): add stubs to solve mypy issues using checklist markers
* test(checkmarks): add fw tests that apply EIPChecklists in pytest.param
* fix(docs): fix bad links to exception tests
* fix(checklists): update test markers to use correct checklist IDs
Update test files to use the correct checklist IDs that match the template:
- Change 'new_precompile' prefix to 'precompile'
- This fixes mkdocs build warnings about missing checklist items
The checklist template uses 'precompile/test/*' IDs but tests were using
'new_precompile/test/*' IDs, causing template lookup failures during
documentation generation.
Also add missing docstrings to fix linting errors.
---------
Co-authored-by: danceratopz <[email protected]>
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ Users can select any of the artifacts depending on their testing needs for their
57
57
- 🐞 Fix bug in ported-from plugin and coverage script that made PRs fail with modified tests that contained no ported tests ([#1661](https://github.com/ethereum/execution-spec-tests/pull/1661)).
58
58
- 🔀 Refactor the `click`-based CLI interface used for pytest-based commands (`fill`, `execute`, `consume`) to make them more extensible ([#1654](https://github.com/ethereum/execution-spec-tests/pull/1654)).
59
59
- 🔀 Split `src/ethereum_test_types/types.py` into several files to improve code organization ([#1665](https://github.com/ethereum/execution-spec-tests/pull/1665)).
60
-
- ✨ Added automatic checklist generation for every EIP inside of the `tests` folder. The checklist is appended to each EIP in the documentation in the "Test Case Reference" section ([#1679](https://github.com/ethereum/execution-spec-tests/pull/1679)).
60
+
- ✨ Added automatic checklist generation for every EIP inside of the `tests` folder. The checklist is appended to each EIP in the documentation in the "Test Case Reference" section ([#1679](https://github.com/ethereum/execution-spec-tests/pull/1679), [#1718](https://github.com/ethereum/execution-spec-tests/pull/1718)).
Copy file name to clipboardExpand all lines: docs/writing_tests/eip_checklist.md
+78-22Lines changed: 78 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -6,30 +6,44 @@ The EIP checklist feature helps track test coverage for EIP implementations by a
6
6
7
7
When implementing tests for an EIP, you can mark specific tests as covering checklist items from the [EIP testing checklist template](../writing_tests/checklist_templates/eip_testing_checklist_template.md). The framework will then generate a filled checklist showing which items have been implemented.
8
8
9
-
## Using the `pytest.mark.eip_checklist` Marker
9
+
## Marking Tests as implementing EIP Checklist Items
10
10
11
-
To mark a test as implementing a specific checklist item:
11
+
To mark a test as implementing a specific checklist item, use the structured `EIPChecklist` class:
new_system_contract = EIP-7702 does not introduce a system contract
95
-
new_precompile = EIP-7702 does not introduce a precompile
107
+
system_contract = EIP-7702 does not introduce a system contract
108
+
precompile = EIP-7702 does not introduce a precompile
96
109
```
97
110
98
111
Format: `checklist_item_id = reason`
99
112
100
113
Both files support partial ID matching, so you can mark entire sections as not applicable:
101
114
115
+
## MyPy Type Checking Support
116
+
117
+
The `EIPChecklist` classes are made callable through a companion `.pyi` stub file that provides proper type hints for mypy. This allows you to use both decorator patterns without type checking errors:
118
+
119
+
```python
120
+
# Both of these work with proper mypy support
121
+
@EIPChecklist.Opcode.Test.StackComplexOperations() # With parentheses
122
+
@EIPChecklist.Opcode.Test.StackComplexOperations# Without parentheses
123
+
```
124
+
125
+
### Regenerating Type Stubs
126
+
127
+
If you modify the `EIPChecklist` class structure in `src/ethereum_test_checklists/eip_checklist.py`, you need to regenerate the type stub file:
128
+
129
+
```bash
130
+
# Generate the stub file (for maintainers):
131
+
uv run generate_checklist_stubs
132
+
133
+
# Preview what would be generated without writing the file
134
+
uv run generate_checklist_stubs --dry-run
135
+
136
+
# Generate to a custom location
137
+
uv run generate_checklist_stubs --output path/to/custom/stubs.pyi
138
+
```
139
+
140
+
The generated stub file (`eip_checklist.pyi`) should be committed to the repository to ensure proper type checking for all developers.
141
+
102
142
```text
103
143
# Mark all system contract items as not applicable
104
-
new_system_contract/ = EIP does not introduce system contracts
144
+
system_contract/ = EIP does not introduce system contracts
105
145
```
106
146
107
147
## Output Format
@@ -135,28 +175,30 @@ Example output snippet:
135
175
| `general/code_coverage/eels` | Run produced tests against EELS... | ✅ | Covered by EELS test suite |
136
176
| `general/code_coverage/test_coverage` | Run coverage on the test code itself... | ✅ | `tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_txs` |
137
177
138
-
## New Transaction Type
178
+
## Transaction Type
139
179
140
180
| ID | Description | Status | Tests |
141
181
| -- | ----------- | ------ | ----- |
142
-
| `new_transaction_type/test/intrinsic_validity/gas_limit/exact` | Provide the exact intrinsic gas... | ✅ | `tests/prague/eip7702_set_code_tx/test_checklist_example.py::test_exact_intrinsic_gas` |
143
-
| `new_transaction_type/test/intrinsic_validity/gas_limit/insufficient` | Provide the exact intrinsic gas minus one... | | |
182
+
| `transaction_type/test/intrinsic_validity/gas_limit/exact` | Provide the exact intrinsic gas... | ✅ | `tests/prague/eip7702_set_code_tx/test_checklist_example.py::test_exact_intrinsic_gas` |
183
+
| `transaction_type/test/intrinsic_validity/gas_limit/insufficient` | Provide the exact intrinsic gas minus one... | | |
144
184
145
-
## New System Contract
185
+
## System Contract
146
186
147
187
| ID | Description | Status | Tests |
148
188
| -- | ----------- | ------ | ----- |
149
-
| `new_system_contract/test/deployment/missing` | Verify block execution behavior... | N/A | EIP-7702 does not introduce a system contract |
189
+
| `system_contract/test/deployment/missing` | Verify block execution behavior... | N/A | EIP-7702 does not introduce a system contract |
150
190
```
151
191
152
192
## Best Practices
153
193
154
194
1.**Start with the checklist**: Review the checklist template before writing tests to ensure comprehensive coverage
155
-
2.**Use descriptive test names**: The test name will appear in the checklist, so make it clear what the test covers
156
-
3.**Mark items as you go**: Add `eip_checklist` markers while writing tests, not as an afterthought
157
-
4.**Document external coverage**: If items are covered by external tools/tests, document this in `eip_checklist_external_coverage.txt`
158
-
5.**Be explicit about N/A items**: Document why items are not applicable in `eip_checklist_not_applicable.txt`
159
-
6.**Use partial IDs wisely**: When a test covers multiple related items, use partial IDs to mark them all
195
+
2.**Use the `EIPChecklist` class**: Use `EIPChecklist.Opcode.Test.GasUsage.Normal` for type safety and IDE autocompletion
196
+
3.**Use descriptive test names**: The test name will appear in the checklist, so make it clear what the test covers
197
+
4.**Mark items as you go**: Add `eip_checklist` markers while writing tests, not as an afterthought
198
+
5.**Document external coverage**: If items are covered by external tools/tests, document this in `eip_checklist_external_coverage.txt`
199
+
6.**Be explicit about N/A items**: Document why items are not applicable in `eip_checklist_not_applicable.txt`
200
+
7.**Use partial IDs wisely**: When a test covers multiple related items, use partial IDs to mark them all
201
+
8.**Verify IDs before using**: Use `str(EIPChecklist.Section.Subsection)` to verify the exact string ID when needed
Copy file name to clipboardExpand all lines: docs/writing_tests/exception_tests.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,11 @@ Exception tests are a special type of test which verify that an invalid transact
6
6
7
7
To test for an exception, the test can use either of the following types from `ethereum_test_exceptions` library:
8
8
9
-
1.[`TransactionException`](../running_tests/test_formats/exceptions.md#transactionexception): To be added to the `error` field of the `Transaction` object, and to the `exception` field of the `Block` object that includes the transaction; this exception type is used when a transaction is invalid, and therefore when included in a block, the block is expected to be invalid too. This is different from valid transactions where an exception during EVM execution is expected (e.g. a revert, or out-of-gas), which can be included in valid blocks.
9
+
1.[`TransactionException`](../library/ethereum_test_exceptions.md#ethereum_test_exceptions.TransactionException): To be added to the `error` field of the `Transaction` object, and to the `exception` field of the `Block` object that includes the transaction; this exception type is used when a transaction is invalid, and therefore when included in a block, the block is expected to be invalid too. This is different from valid transactions where an exception during EVM execution is expected (e.g. a revert, or out-of-gas), which can be included in valid blocks.
10
10
11
11
For an example, see [`eip3860_initcode.test_initcode.test_contract_creating_tx`](../tests/shanghai/eip3860_initcode/test_initcode/test_contract_creating_tx.md) which raises `TransactionException.INITCODE_SIZE_EXCEEDED` in the case that the initcode size exceeds the maximum allowed size.
12
12
13
-
2.[`BlockException`](../running_tests/test_formats/exceptions.md#blockexception): To be added to the `exception` field of the `Block` object; this exception type is used when a block is expected to be invalid, but the exception is related to a block property, e.g. an invalid value of the block header.
13
+
2.[`BlockException`](../library/ethereum_test_exceptions.md#ethereum_test_exceptions.BlockException): To be added to the `exception` field of the `Block` object; this exception type is used when a block is expected to be invalid, but the exception is related to a block property, e.g. an invalid value of the block header.
14
14
15
15
For an example, see [`eip4844_blobs.test_excess_blob_gas.test_invalid_static_excess_blob_gas`](../tests/cancun/eip4844_blobs/test_excess_blob_gas/test_invalid_static_excess_blob_gas.md) which raises `BlockException.INCORRECT_EXCESS_BLOB_GAS` in the case that the `excessBlobGas` remains unchanged
16
16
but the parent blobs included are not `TARGET_BLOBS_PER_BLOCK`.
@@ -19,7 +19,7 @@ Although exceptions can be combined with the `|` operator to indicate that a tes
19
19
20
20
## Adding a new exception
21
21
22
-
If a test requires a new exception, because none of the existing ones is suitable for the test, a new exception can be added to either [`TransactionException`](../running_tests/test_formats/exceptions.md#transactionexception) or [`BlockException`](../running_tests/test_formats/exceptions.md#blockexception) classes.
22
+
If a test requires a new exception, because none of the existing ones is suitable for the test, a new exception can be added to either [`TransactionException`](../library/ethereum_test_exceptions.md#ethereum_test_exceptions.TransactionException) or [`BlockException`](../library/ethereum_test_exceptions.md#ethereum_test_exceptions.BlockException) classes.
23
23
24
24
The new exception should be added as a new enum value, and the docstring of the attribute should be a string that describes the exception.
0 commit comments