|
5 | 5 | from pyk.kdist import kdist |
6 | 6 | from pyk.ktool.krun import llvm_interpret |
7 | 7 |
|
8 | | -from .gst_to_kore import filter_gst_keys, gst_to_kore |
| 8 | +from .config import DEFAULT_SCHEDULE |
| 9 | +from .gst_to_kore import SCHEDULE_MAPPING, filter_gst_keys, gst_to_kore |
9 | 10 |
|
10 | 11 | if TYPE_CHECKING: |
11 | 12 | from collections.abc import Iterator |
|
15 | 16 |
|
16 | 17 |
|
17 | 18 | def iterate_gst( |
18 | | - gst_data: dict, schedule: str, mode: str, chainid: int, usegas: bool, skipped_keys: frozenset[str] = frozenset() |
| 19 | + gst_data: dict, |
| 20 | + mode: str, |
| 21 | + chainid: int, |
| 22 | + usegas: bool, |
| 23 | + skipped_keys: frozenset[str] = frozenset(), |
| 24 | + schedule: str | None = None, |
19 | 25 | ) -> Iterator[tuple[str, App]]: |
20 | 26 | """Yield (test_name, kore_pattern) for each test in GST data after filtering discarded keys.""" |
21 | 27 | for test_name, test in gst_data.items(): |
22 | 28 | if test_name in skipped_keys: |
23 | 29 | continue |
| 30 | + test_schedule = _resolve_schedule(test, schedule) |
24 | 31 | gst_filtered = {test_name: filter_gst_keys(test)} |
25 | | - yield test_name, gst_to_kore(gst_filtered, schedule, mode, chainid, usegas) |
| 32 | + yield test_name, gst_to_kore(gst_filtered, test_schedule, mode, chainid, usegas) |
| 33 | + |
| 34 | + |
| 35 | +def _resolve_schedule(test: dict, fallback: str | None) -> str: |
| 36 | + """Return schedule from test's network field, falling back to provided schedule or DEFAULT_SCHEDULE.""" |
| 37 | + network = test.get('network') |
| 38 | + if network is not None: |
| 39 | + if network not in SCHEDULE_MAPPING: |
| 40 | + raise ValueError(f'Unknown network {network}.') |
| 41 | + return SCHEDULE_MAPPING[network] |
| 42 | + return fallback or DEFAULT_SCHEDULE |
26 | 43 |
|
27 | 44 |
|
28 | 45 | def interpret(init_kore: Any, *, check: bool = True) -> Pattern: |
|
0 commit comments