From 16887215541b416a74edf8f5fcb5b809091352e8 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Sun, 22 Sep 2019 09:54:17 -0500 Subject: [PATCH] fix up attesation reward tests --- .../test_process_rewards_and_penalties.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_rewards_and_penalties.py b/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_rewards_and_penalties.py index 114898abf..40f6d781e 100644 --- a/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_rewards_and_penalties.py +++ b/test_libs/pyspec/eth2spec/test/phase_0/epoch_processing/test_process_rewards_and_penalties.py @@ -34,13 +34,19 @@ def test_genesis_epoch_no_attestations_no_penalties(spec, state): @spec_state_test def test_genesis_epoch_full_attestations_no_rewards(spec, state): attestations = [] - for slot in range(spec.SLOTS_PER_EPOCH - spec.MIN_ATTESTATION_INCLUSION_DELAY - 1): - attestation = get_valid_attestation(spec, state) - fill_aggregate_attestation(spec, state, attestation, signed=True) - attestations.append(attestation) + for slot in range(spec.SLOTS_PER_EPOCH - 1): + # create an attestation for each slot + if slot < spec.SLOTS_PER_EPOCH: + attestation = get_valid_attestation(spec, state) + fill_aggregate_attestation(spec, state, attestation, signed=True) + attestations.append(attestation) + # fill each created slot in state after inclusion delay + if slot - spec.MIN_ATTESTATION_INCLUSION_DELAY >= 0: + include_att = attestations[slot - spec.MIN_ATTESTATION_INCLUSION_DELAY] + add_attestations_to_state(spec, state, [include_att], state.slot) next_slot(spec, state) - add_attestations_to_state(spec, state, attestations, state.slot + spec.MIN_ATTESTATION_INCLUSION_DELAY) + # ensure has not cross the epoch boundary assert spec.compute_epoch_of_slot(state.slot) == spec.GENESIS_EPOCH pre_state = deepcopy(state)