From 2af39ad4694a1ad7eb91856e3820d2d50c21953f Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 30 Sep 2019 13:58:48 +0900 Subject: [PATCH] fix shard period sanity test --- .../pyspec/eth2spec/test/helpers/phase1/shard_block.py | 6 +++--- .../eth2spec/test/phase_1/sanity/test_shard_blocks.py | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test_libs/pyspec/eth2spec/test/helpers/phase1/shard_block.py b/test_libs/pyspec/eth2spec/test/helpers/phase1/shard_block.py index ea5783655..a339a0e70 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/phase1/shard_block.py +++ b/test_libs/pyspec/eth2spec/test/helpers/phase1/shard_block.py @@ -41,11 +41,11 @@ def build_empty_shard_block(spec, if slot is None: slot = shard_state.slot - parent_epoch = spec.compute_epoch_of_shard_slot(shard_state.latest_block_header.slot) - if parent_epoch * spec.SLOTS_PER_EPOCH == beacon_state.slot: + epoch = spec.compute_epoch_of_shard_slot(slot) + if epoch * spec.SLOTS_PER_EPOCH == beacon_state.slot: beacon_block_root = spec.signing_root(beacon_state.latest_block_header) else: - beacon_block_root = spec.get_block_root(beacon_state, parent_epoch) + beacon_block_root = spec.get_block_root(beacon_state, epoch) previous_block_header = deepcopy(shard_state.latest_block_header) if previous_block_header.state_root == spec.Hash(): diff --git a/test_libs/pyspec/eth2spec/test/phase_1/sanity/test_shard_blocks.py b/test_libs/pyspec/eth2spec/test/phase_1/sanity/test_shard_blocks.py index 2669ffb53..51575f2d5 100644 --- a/test_libs/pyspec/eth2spec/test/phase_1/sanity/test_shard_blocks.py +++ b/test_libs/pyspec/eth2spec/test/phase_1/sanity/test_shard_blocks.py @@ -154,6 +154,13 @@ def test_empty_shard_period_transition(spec, state): shard_state.newer_committee_negative_deltas[0] = stub_delta slot = shard_state.slot + spec.SHARD_SLOTS_PER_EPOCH * spec.EPOCHS_PER_SHARD_PERIOD + beacon_state.slot = spec.compute_epoch_of_shard_slot(slot) * spec.SLOTS_PER_EPOCH - 4 + spec.process_slots(beacon_state, spec.compute_epoch_of_shard_slot(slot) * spec.SLOTS_PER_EPOCH) + + # all validators get slashed for not revealing keys + # undo this to allow for a block proposal + for index in range(len(beacon_state.validators)): + beacon_state.validators[index].slashed = False block = build_empty_shard_block(spec, beacon_state, shard_state, slot=slot, signed=True) yield 'pre', shard_state