fix shard period sanity test

This commit is contained in:
Danny Ryan 2019-09-30 13:58:48 +09:00
parent a5fb9408ae
commit 2af39ad469
No known key found for this signature in database
GPG Key ID: 2765A792E42CE07A
2 changed files with 10 additions and 3 deletions

View File

@ -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():

View File

@ -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