Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run tests against future forks by default #2635

Merged
merged 1 commit into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
run tests against future forks by default
Some tests are currently restricted to a single phase using @with_phases
even though they could likely run unchanged in later phases. This patch
changes the default for such tests to also run in later phases. If the
beacon chain changes enough in later phases to break these tests, this
highlights that the tests need to be adjusted or extended accordingly.
  • Loading branch information
etan-status committed Sep 30, 2021
commit 939e6c7e8eab56a8cce197b5d25218026198b0c9
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from eth2spec.test.context import (
spec_state_test,
with_phases,
with_altair_and_later,
)
from eth2spec.test.helpers.constants import ALTAIR
from eth2spec.test.helpers.merkle import build_proof


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
def test_next_sync_committee_merkle_proof(spec, state):
yield "state", state
Expand All @@ -25,7 +24,7 @@ def test_next_sync_committee_merkle_proof(spec, state):
)


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
def test_finality_root_merkle_proof(spec, state):
yield "state", state
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from eth2spec.test.context import (
with_altair_and_later,
spec_state_test,
with_altair_and_later,
)
from eth2spec.test.helpers.state import (
transition_to,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from eth2spec.test.context import (
spec_state_test,
with_phases,
with_altair_and_later,
)
from eth2spec.test.helpers.constants import ALTAIR


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
def test_weight_denominator(spec, state):
assert (
Expand All @@ -17,7 +16,7 @@ def test_weight_denominator(spec, state):
) == spec.WEIGHT_DENOMINATOR


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
def test_inactivity_score(spec, state):
assert spec.config.INACTIVITY_SCORE_BIAS <= spec.config.INACTIVITY_SCORE_RECOVERY_RATE
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
from eth2spec.test.context import (
spec_state_test,
with_presets,
with_phases,
with_altair_and_later,
)
from eth2spec.test.helpers.attestations import next_epoch_with_attestations
from eth2spec.test.helpers.block import (
build_empty_block,
build_empty_block_for_next_slot,
)
from eth2spec.test.helpers.constants import (
ALTAIR,
MINIMAL,
)
from eth2spec.test.helpers.constants import MINIMAL
from eth2spec.test.helpers.state import (
next_slots,
state_transition_and_sign_block,
Expand All @@ -22,7 +19,7 @@
from eth2spec.test.helpers.merkle import build_proof


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
def test_process_light_client_update_not_updated(spec, state):
pre_snapshot = spec.LightClientSnapshot(
Expand Down Expand Up @@ -81,7 +78,7 @@ def test_process_light_client_update_not_updated(spec, state):
assert store.snapshot == pre_snapshot


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
@with_presets([MINIMAL], reason="too slow")
def test_process_light_client_update_timeout(spec, state):
Expand Down Expand Up @@ -147,7 +144,7 @@ def test_process_light_client_update_timeout(spec, state):
assert store.snapshot.header == update.header


@with_phases([ALTAIR])
@with_altair_and_later
@spec_state_test
@with_presets([MINIMAL], reason="too slow")
def test_process_light_client_update_finality_updated(spec, state):
Expand Down
4 changes: 2 additions & 2 deletions tests/core/pyspec/eth2spec/test/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ def is_post_merge(spec):
return spec.fork not in FORKS_BEFORE_MERGE


with_altair_and_later = with_phases([ALTAIR, MERGE])
with_merge_and_later = with_phases([MERGE]) # TODO: include sharding when spec stabilizes.
with_altair_and_later = with_all_phases_except([PHASE0])
with_merge_and_later = with_all_phases_except([PHASE0, ALTAIR])


def only_generator(reason):
Expand Down
6 changes: 4 additions & 2 deletions tests/generators/merkle/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from eth2spec.test.helpers.constants import ALTAIR
from eth2spec.test.helpers.constants import ALTAIR, MERGE
from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators


if __name__ == "__main__":
altair_mods = {key: 'eth2spec.test.altair.merkle.test_' + key for key in [
'single_proof',
]}
merge_mods = altair_mods

all_mods = {
ALTAIR: altair_mods
ALTAIR: altair_mods,
MERGE: merge_mods,
}

run_state_test_generators(runner_name="merkle", all_mods=all_mods)