Skip to content

Commit ff4d8ba

Browse files
committed
Add manifest.yaml to each test vector to make metadata self-contained and test cases easier to share and verify
1 parent a1ce256 commit ff4d8ba

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

tests/core/pyspec/eth2spec/gen_helpers/gen_base/dumper.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ def dump_ssz(self, test_case: TestCase, name: str, data: bytes) -> None:
7070
with path.open("wb") as f:
7171
f.write(compress(data))
7272

73+
def dump_manifest(self, test_case: TestCase) -> None:
74+
"""Write manifest.yml file containing test case metadata."""
75+
manifest_data = {
76+
'config_name': test_case.preset_name,
77+
'fork_name': test_case.fork_name,
78+
'runner_name': test_case.runner_name,
79+
'handler_name': test_case.handler_name,
80+
'suite_name': test_case.suite_name,
81+
'case_name': test_case.case_name,
82+
}
83+
self._dump_yaml(test_case, "manifest", manifest_data, self.default_yaml)
84+
7385
def _dump_yaml(self, test_case: TestCase, name: str, data: any, yaml_encoder: YAML) -> None:
7486
"""Helper to write YAML files for test case."""
7587
path = test_case.dir / f"{name}.yaml"

tests/core/pyspec/eth2spec/gen_helpers/gen_base/gen_runner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ def execute_test(test_case: TestCase, dumper: Dumper):
109109
if meta:
110110
dumper.dump_meta(test_case, meta)
111111

112+
# Always write manifest.yml for every test case
113+
dumper.dump_manifest(test_case)
114+
112115

113116
def run_generator(input_test_cases: Iterable[TestCase], args=None):
114117
start_time = time.time()

tests/formats/README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ testing.
2222
- [Common output formats](#common-output-formats)
2323
- [Special output parts](#special-output-parts)
2424
- [`meta.yaml`](#metayaml)
25+
- [`manifest.yaml`](#manifestyaml)
2526
- [`config.yaml`](#configyaml)
2627
- [Config sourcing](#config-sourcing)
2728
- [Note for implementers](#note-for-implementers)
@@ -213,6 +214,28 @@ bls_setting: int -- optional, can have 3 different values:
213214
2: known as "BLS ignored" - if the test validity is strictly dependent on BLS being OFF
214215
```
215216

217+
##### `manifest.yaml`
218+
219+
Included in every test case. Contains metadata that identifies the test vector:
220+
221+
```yaml
222+
config_name: minimal # Configuration preset (mainnet, minimal, general)
223+
fork_name: phase0 # Fork/phase name
224+
runner_name: bls # Test runner category
225+
handler_name: eth_aggregate_pubkeys # Specific handler
226+
suite_name: bls # Test suite name
227+
case_name: eth_aggregate_pubkeys_valid_0 # Individual test case name
228+
```
229+
230+
This metadata duplicates what is already encoded in the directory path:
231+
232+
```
233+
tests/<config_name>/<fork_name>/<runner_name>/<handler_name>/<suite_name>/<case_name>/
234+
```
235+
236+
Having it in a file means test vectors can be moved or distributed without
237+
losing context.
238+
216239
##### `config.yaml`
217240

218241
The runtime-configurables may be different for specific tests. When present,
@@ -252,7 +275,7 @@ The basic pattern for test-suite loading and running is:
252275
`operations > deposits`). Again, repeat for each if running all.
253276
4. Select a test suite. Or repeat for each.
254277
5. Select a test case. Or repeat for each.
255-
6. Load the parts of the case. And `meta.yaml` if present.
278+
6. Load the parts of the case. `manifest.yaml` and `meta.yaml` if present.
256279
7. Run the test, as defined by the test format.
257280

258281
Step 1 may be a step with compile time selection of a configuration, if desired

0 commit comments

Comments
 (0)