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