Skip to content

Commit a5cea90

Browse files
committed
chore(test-forks): include sibling BPO forks in --until ranges
1 parent 852715c commit a5cea90

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

packages/testing/src/execution_testing/forks/helpers.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,38 @@ def get_last_descendants(
195195
return resulting_forks
196196

197197

198+
def get_bpo_sibling_forks(
199+
forks: Set[Type[BaseFork]] | FrozenSet[Type[BaseFork]],
200+
forks_from: Set[Type[BaseFork]],
201+
forks_until: Set[Type[BaseFork]],
202+
) -> Set[Type[BaseFork]]:
203+
"""
204+
Return BPO forks that branch off an ancestor of an `--until` fork.
205+
206+
BPO (Blob Parameter Only) forks form a chain hanging off the fork
207+
they extend (e.g. the `BPO3`/`BPO4`/`BPO5` chain branches off `BPO2`).
208+
A later fork such as `Amsterdam` descends from that same `BPO2` on a
209+
parallel branch, so an ancestry-based `--until=Amsterdam` range never
210+
reaches the BPO chain. Return those siblings, bounded below by
211+
`forks_from`, so filling until such a fork still exercises the
212+
blob-parameter paths the BPO forks cover.
213+
"""
214+
siblings: Set[Type[BaseFork]] = set()
215+
for fork_until in forks_until:
216+
if issubclass(fork_until, TransitionBaseClass):
217+
continue
218+
for fork in forks:
219+
if not fork.bpo_fork():
220+
continue
221+
if fork <= fork_until or fork >= fork_until:
222+
continue
223+
if fork.non_bpo_ancestor() <= fork_until and any(
224+
fork >= fork_from for fork_from in forks_from
225+
):
226+
siblings.add(fork)
227+
return siblings
228+
229+
198230
def get_selected_fork_set(
199231
*,
200232
single_fork: Set[Type[BaseFork]],
@@ -225,6 +257,9 @@ def get_selected_fork_set(
225257
for fork_until in forks_until:
226258
if issubclass(fork_until, TransitionBaseClass):
227259
selected_fork_set.discard(fork_until.transitions_to())
260+
selected_fork_set |= get_bpo_sibling_forks(
261+
ALL_FORKS, forks_from, forks_until
262+
)
228263
selected_fork_set_with_transitions: Set[
229264
Type[BaseFork | TransitionBaseClass]
230265
] = set() | selected_fork_set

packages/testing/src/execution_testing/forks/tests/test_forks.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
BPO2,
1414
BPO3,
1515
BPO4,
16+
BPO5,
1617
Amsterdam,
1718
Berlin,
1819
Cancun,
@@ -682,6 +683,55 @@ def test_transition_from_normal_until(self) -> None:
682683
assert BPO1ToBPO2AtTime15k in result
683684
assert BPO2ToAmsterdamAtTime15k not in result
684685

686+
def test_until_amsterdam_includes_bpo_siblings(self) -> None:
687+
"""`--until=Amsterdam` pulls in the parallel BPO branch."""
688+
result = get_selected_fork_set(
689+
single_fork=set(),
690+
forks_from=set(),
691+
forks_until={Amsterdam},
692+
)
693+
normal = self._normal_forks(result)
694+
assert {BPO1, BPO2, BPO3, BPO4, BPO5, Amsterdam} <= normal
695+
assert BPO2ToBPO3AtTime15k in result
696+
assert BPO3ToBPO4AtTime15k in result
697+
698+
def test_from_osaka_until_amsterdam_spans_bpo_branch(self) -> None:
699+
"""`--from=Osaka --until=Amsterdam` spans the full BPO branch."""
700+
result = get_selected_fork_set(
701+
single_fork=set(),
702+
forks_from={Osaka},
703+
forks_until={Amsterdam},
704+
)
705+
assert self._normal_forks(result) == {
706+
Osaka,
707+
BPO1,
708+
BPO2,
709+
BPO3,
710+
BPO4,
711+
BPO5,
712+
Amsterdam,
713+
}
714+
715+
def test_until_bpo2_excludes_later_bpo_siblings(self) -> None:
716+
"""`--until=BPO2` must not pull in the later BPO branch."""
717+
result = get_selected_fork_set(
718+
single_fork=set(),
719+
forks_from=set(),
720+
forks_until={BPO2},
721+
)
722+
normal = self._normal_forks(result)
723+
assert {BPO1, BPO2} <= normal
724+
assert not ({BPO3, BPO4, BPO5} & normal)
725+
726+
def test_from_amsterdam_until_amsterdam_excludes_bpos(self) -> None:
727+
"""`--from=Amsterdam --until=Amsterdam` stays Amsterdam-only."""
728+
result = get_selected_fork_set(
729+
single_fork=set(),
730+
forks_from={Amsterdam},
731+
forks_until={Amsterdam},
732+
)
733+
assert self._normal_forks(result) == {Amsterdam}
734+
685735

686736
def test_blob_constants() -> None: # noqa: D103
687737
assert Osaka.get_blob_constant("AMOUNT_CELL_PROOFS") == 128

0 commit comments

Comments
 (0)