From f75e3dccb2041cec7884266a7a348decd1051074 Mon Sep 17 00:00:00 2001 From: protolambda Date: Sat, 22 Jun 2019 02:03:43 +0200 Subject: [PATCH] test old and future target epoch in attestation --- .../test_process_attestation.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py index 79af0b202..59e99ac0c 100644 --- a/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py +++ b/test_libs/pyspec/eth2spec/test/phase_0/block_processing/test_process_attestation.py @@ -162,6 +162,33 @@ def test_invalid_shard(spec, state): yield from run_attestation_processing(spec, state, attestation, False) +@with_all_phases +@spec_state_test +def test_old_target_epoch(spec, state): + assert spec.MIN_ATTESTATION_INCLUSION_DELAY < spec.SLOTS_PER_EPOCH * 2 + + attestation = get_valid_attestation(spec, state, signed=True) + + state.slot = spec.SLOTS_PER_EPOCH * 2 # target epoch will be too old to handle + + yield from run_attestation_processing(spec, state, attestation, False) + + +@with_all_phases +@spec_state_test +def test_future_target_epoch(spec, state): + assert spec.MIN_ATTESTATION_INCLUSION_DELAY < spec.SLOTS_PER_EPOCH * 2 + + attestation = get_valid_attestation(spec, state) + + state.slot += spec.MIN_ATTESTATION_INCLUSION_DELAY + + attestation.data.target_epoch = spec.get_current_epoch(state) + 1 # target epoch will be too new to handle + sign_attestation(spec, state, attestation) + + yield from run_attestation_processing(spec, state, attestation, False) + + @with_all_phases @spec_state_test def test_new_source_epoch(spec, state):