update altair tests to not collide with Merge + fix merge test triggers

This commit is contained in:
protolambda 2021-05-05 16:03:52 +02:00
parent ff3a82e0f3
commit 865d7db5ca
No known key found for this signature in database
GPG Key ID: EC89FDBB2B4C7623
8 changed files with 39 additions and 33 deletions

View File

@ -17,7 +17,7 @@ from eth2spec.test.helpers.sync_committee import (
)
from eth2spec.test.context import (
expect_assertion_error,
with_all_phases_except,
with_altair_and_later,
with_configs,
spec_state_test,
always_bls,
@ -62,7 +62,7 @@ def get_committee_indices(spec, state, duplicates=False):
state.randao_mixes[randao_index] = hash(state.randao_mixes[randao_index])
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
def test_invalid_signature_missing_participant(spec, state):
@ -84,7 +84,7 @@ def test_invalid_signature_missing_participant(spec, state):
yield from run_sync_committee_processing(spec, state, block, expect_exception=True)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
def test_invalid_signature_extra_participant(spec, state):
@ -197,7 +197,7 @@ def run_successful_sync_committee_test(spec, state, committee, committee_bits):
)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_configs([MINIMAL], reason="to create nonduplicate committee")
@spec_state_test
def test_sync_committee_rewards_nonduplicate_committee(spec, state):
@ -213,7 +213,7 @@ def test_sync_committee_rewards_nonduplicate_committee(spec, state):
yield from run_successful_sync_committee_test(spec, state, committee, committee_bits)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_configs([MAINNET], reason="to create duplicate committee")
@spec_state_test
def test_sync_committee_rewards_duplicate_committee(spec, state):
@ -229,7 +229,7 @@ def test_sync_committee_rewards_duplicate_committee(spec, state):
yield from run_successful_sync_committee_test(spec, state, committee, committee_bits)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
def test_sync_committee_rewards_not_full_participants(spec, state):
@ -240,7 +240,7 @@ def test_sync_committee_rewards_not_full_participants(spec, state):
yield from run_successful_sync_committee_test(spec, state, committee, committee_bits)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
def test_sync_committee_rewards_empty_participants(spec, state):
@ -250,7 +250,7 @@ def test_sync_committee_rewards_empty_participants(spec, state):
yield from run_successful_sync_committee_test(spec, state, committee, committee_bits)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
def test_invalid_signature_past_block(spec, state):
@ -289,7 +289,7 @@ def test_invalid_signature_past_block(spec, state):
yield from run_sync_committee_processing(spec, state, invalid_block, expect_exception=True)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_configs([MINIMAL], reason="to produce different committee sets")
@spec_state_test
@always_bls
@ -326,7 +326,7 @@ def test_invalid_signature_previous_committee(spec, state):
yield from run_sync_committee_processing(spec, state, block, expect_exception=True)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
@with_configs([MINIMAL], reason="too slow")

View File

@ -2,7 +2,7 @@ from eth2spec.test.context import (
always_bls,
spec_state_test,
spec_test,
with_all_phases_except,
with_altair_and_later,
with_configs,
with_custom_state,
single_phase,
@ -49,7 +49,7 @@ def run_sync_committees_progress_test(spec, state):
assert state.next_sync_committee == third_sync_committee
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
@with_configs([MINIMAL], reason="too slow")
@ -60,7 +60,7 @@ def test_sync_committees_progress_genesis(spec, state):
yield from run_sync_committees_progress_test(spec, state)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
@always_bls
@with_configs([MINIMAL], reason="too slow")
@ -73,7 +73,7 @@ def test_sync_committees_progress_not_genesis(spec, state):
yield from run_sync_committees_progress_test(spec, state)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_custom_state(balances_fn=misc_balances, threshold_fn=lambda spec: spec.EJECTION_BALANCE)
@spec_test
@single_phase

View File

@ -11,9 +11,8 @@ from eth2spec.test.helpers.block import (
from eth2spec.test.helpers.sync_committee import (
compute_aggregate_sync_committee_signature,
)
from eth2spec.test.helpers.constants import PHASE0
from eth2spec.test.context import (
with_all_phases_except,
with_altair_and_later,
spec_state_test,
)
@ -40,46 +39,46 @@ def run_sync_committee_sanity_test(spec, state, fraction_full=1.0):
yield 'post', state
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_full_sync_committee_committee(spec, state):
next_epoch(spec, state)
yield from run_sync_committee_sanity_test(spec, state, fraction_full=1.0)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_half_sync_committee_committee(spec, state):
next_epoch(spec, state)
yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.5)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_empty_sync_committee_committee(spec, state):
next_epoch(spec, state)
yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.0)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_full_sync_committee_committee_genesis(spec, state):
yield from run_sync_committee_sanity_test(spec, state, fraction_full=1.0)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_half_sync_committee_committee_genesis(spec, state):
yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.5)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_empty_sync_committee_committee_genesis(spec, state):
yield from run_sync_committee_sanity_test(spec, state, fraction_full=0.0)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@spec_state_test
def test_inactivity_scores(spec, state):
for _ in range(spec.MIN_EPOCHS_TO_INACTIVITY_PENALTY + 2):

View File

@ -8,7 +8,7 @@ from eth2spec.utils import bls
from eth2spec.utils.bls import only_with_bls
from eth2spec.test.context import (
PHASE0,
with_all_phases_except,
with_altair_and_later,
with_state,
)
@ -25,7 +25,7 @@ def ensure_assignments_in_sync_committee(
assert spec.is_assigned_to_sync_committee(state, epoch, validator_index)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_state
def test_is_assigned_to_sync_committee(phases, spec, state):
epoch = spec.get_current_epoch(state)
@ -91,7 +91,7 @@ def _get_sync_committee_signature(
@only_with_bls()
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_state
def test_process_sync_committee_contributions(phases, spec, state):
# skip over slots at genesis
@ -144,7 +144,7 @@ def _subnet_for_sync_committee_index(spec, i):
return i // (spec.SYNC_COMMITTEE_SIZE // spec.SYNC_COMMITTEE_SUBNET_COUNT)
@with_all_phases_except([PHASE0])
@with_altair_and_later
@with_state
def test_compute_subnets_for_sync_committee(state, spec, phases):
some_sync_committee_members = list(

View File

@ -367,12 +367,20 @@ def with_configs(configs, reason=None):
def is_post_altair(spec):
if spec.fork == MERGE: # TODO: remove parallel Altair-Merge condition after rebase.
return False
if spec.fork in FORKS_BEFORE_ALTAIR:
return False
return True
def is_post_merge(spec):
if spec.fork == ALTAIR: # TODO: remove parallel Altair-Merge condition after rebase.
return False
if spec.fork in FORKS_BEFORE_MERGE:
return False
return True
with_altair_and_later = with_phases([ALTAIR]) # TODO: include Merge, but not until Merge work is rebased.
with_merge_and_later = with_phases([MERGE])

View File

@ -96,6 +96,8 @@ def build_empty_block(spec, state, slot=None):
empty_block.body.sync_aggregate.sync_committee_signature = spec.G2_POINT_AT_INFINITY
if is_post_merge(spec):
if not hasattr(state, 'latest_execution_payload_header'):
raise Exception("panic!!!")
empty_block.body.execution_payload = build_empty_execution_payload(spec, state)
apply_randao_reveal(spec, state, empty_block)

View File

@ -1,8 +1,5 @@
from eth2spec.test.helpers.constants import PHASE0, ALTAIR
from eth2spec.test.helpers.execution_payload import build_empty_execution_payload
from eth2spec.test.context import spec_state_test, expect_assertion_error, always_bls, with_all_phases_except
with_merge_and_later = with_all_phases_except([PHASE0, ALTAIR])
from eth2spec.test.context import spec_state_test, expect_assertion_error, always_bls, with_merge_and_later
def run_execution_payload_processing(spec, state, execution_payload, valid=True, execution_valid=True):

View File

@ -5,11 +5,11 @@ from eth2spec.test.helpers.block import (
build_empty_block_for_next_slot
)
from eth2spec.test.context import (
with_all_phases, spec_state_test
with_merge_and_later, spec_state_test
)
@with_all_phases
@with_merge_and_later
@spec_state_test
def test_empty_block_transition(spec, state):
yield 'pre', state