Somehow I had indented with 5 spaces everywhere.
This commit is contained in:
parent
f421850dc9
commit
9f2d06b2e7
|
@ -164,7 +164,7 @@ def on_attestation(store: Store, attestation: Attestation) -> None:
|
|||
for i in indexed_attestation.custody_bit_0_indices + indexed_attestation.custody_bit_1_indices:
|
||||
if i not in store.latest_targets or attestation.data.target_epoch > store.latest_targets[i].epoch:
|
||||
store.latest_targets[i] = Target(
|
||||
epoch = attestation.data.target_epoch,
|
||||
root = attestation.data.target_root,
|
||||
epoch=attestation.data.target_epoch,
|
||||
root=attestation.data.target_root,
|
||||
)
|
||||
```
|
||||
|
|
|
@ -12,57 +12,57 @@ from eth2spec.test.helpers.state import next_slot
|
|||
@with_all_phases
|
||||
@spec_state_test
|
||||
def test_basic(spec, state):
|
||||
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))
|
||||
yield 'pre', state
|
||||
state.latest_block_header = spec.BeaconBlockHeader(body_root=hash_tree_root(spec.BeaconBlockBody()))
|
||||
yield 'pre', state
|
||||
|
||||
# Initialization
|
||||
store = spec.get_genesis_store(state)
|
||||
blocks = []
|
||||
time = 100
|
||||
spec.on_tick(store, time)
|
||||
assert store.time == time
|
||||
store = spec.get_genesis_store(state)
|
||||
blocks = []
|
||||
time = 100
|
||||
spec.on_tick(store, time)
|
||||
assert store.time == time
|
||||
|
||||
# On receiving a block of `GENESIS_SLOT + 1` slot
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
blocks.append(block)
|
||||
spec.on_block(store, block)
|
||||
assert store.blocks[signing_root(block)] == block
|
||||
# On receiving a block of `GENESIS_SLOT + 1` slot
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
blocks.append(block)
|
||||
spec.on_block(store, block)
|
||||
assert store.blocks[signing_root(block)] == block
|
||||
|
||||
# On receiving a block of next epoch
|
||||
store.time = time + spec.SECONDS_PER_SLOT * spec.SLOTS_PER_EPOCH
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
block.slot += spec.SLOTS_PER_EPOCH
|
||||
blocks.append(block)
|
||||
# On receiving a block of next epoch
|
||||
store.time = time + spec.SECONDS_PER_SLOT * spec.SLOTS_PER_EPOCH
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
block.slot += spec.SLOTS_PER_EPOCH
|
||||
blocks.append(block)
|
||||
|
||||
spec.on_block(store, block)
|
||||
assert store.blocks[signing_root(block)] == block
|
||||
yield 'blocks', blocks, List[spec.BeaconBlock]
|
||||
spec.on_block(store, block)
|
||||
assert store.blocks[signing_root(block)] == block
|
||||
yield 'blocks', blocks, List[spec.BeaconBlock]
|
||||
|
||||
# TODO: add tests for justified_root and finalized_root
|
||||
yield 'post', state
|
||||
# TODO: add tests for justified_root and finalized_root
|
||||
yield 'post', state
|
||||
|
||||
|
||||
@with_all_phases
|
||||
@spec_state_test
|
||||
def test_on_attestation(spec, state):
|
||||
yield 'pre', state
|
||||
yield 'pre', state
|
||||
|
||||
store = spec.get_genesis_store(state)
|
||||
time = 100
|
||||
spec.on_tick(store, time)
|
||||
store = spec.get_genesis_store(state)
|
||||
time = 100
|
||||
spec.on_tick(store, time)
|
||||
|
||||
next_slot(spec, state)
|
||||
next_slot(spec, state)
|
||||
|
||||
attestation = get_valid_attestation(spec, state, slot=1)
|
||||
yield 'attestation', attestation
|
||||
indexed_attestation = spec.convert_to_indexed(state, attestation)
|
||||
spec.on_attestation(store, attestation)
|
||||
assert (
|
||||
store.latest_targets[indexed_attestation.custody_bit_0_indices[0]] ==
|
||||
spec.Target(
|
||||
epoch = attestation.data.target_epoch,
|
||||
root = attestation.data.target_root,
|
||||
)
|
||||
)
|
||||
attestation = get_valid_attestation(spec, state, slot=1)
|
||||
yield 'attestation', attestation
|
||||
indexed_attestation = spec.convert_to_indexed(state, attestation)
|
||||
spec.on_attestation(store, attestation)
|
||||
assert (
|
||||
store.latest_targets[indexed_attestation.custody_bit_0_indices[0]] ==
|
||||
spec.Target(
|
||||
epoch=attestation.data.target_epoch,
|
||||
root=attestation.data.target_root,
|
||||
)
|
||||
)
|
||||
|
||||
yield 'post', state
|
||||
yield 'post', state
|
||||
|
|
|
@ -131,7 +131,7 @@ class Container(object):
|
|||
def get_field_values(self):
|
||||
cls = self.__class__
|
||||
return [getattr(self, field) for field in cls.get_field_names()]
|
||||
|
||||
|
||||
def copy(self):
|
||||
return copy.deepcopy(self)
|
||||
|
||||
|
|
Loading…
Reference in New Issue