2019-05-23 21:32:21 +00:00
|
|
|
from eth2spec.test.helpers.state import get_state_root
|
2019-05-30 20:57:18 +00:00
|
|
|
from eth2spec.test.context import spec_state_test, with_all_phases
|
2019-05-23 21:32:21 +00:00
|
|
|
|
|
|
|
|
2019-05-30 20:57:18 +00:00
|
|
|
@with_all_phases
|
2019-05-23 21:32:21 +00:00
|
|
|
@spec_state_test
|
2019-05-30 20:57:18 +00:00
|
|
|
def test_slots_1(spec, state):
|
2019-05-23 21:32:21 +00:00
|
|
|
pre_slot = state.slot
|
|
|
|
pre_root = state.hash_tree_root()
|
|
|
|
yield 'pre', state
|
|
|
|
|
|
|
|
slots = 1
|
|
|
|
yield 'slots', slots
|
2019-05-30 20:57:18 +00:00
|
|
|
spec.process_slots(state, state.slot + slots)
|
2019-05-23 21:32:21 +00:00
|
|
|
|
|
|
|
yield 'post', state
|
|
|
|
assert state.slot == pre_slot + 1
|
2019-05-30 20:57:18 +00:00
|
|
|
assert get_state_root(spec, state, pre_slot) == pre_root
|
2019-05-23 21:32:21 +00:00
|
|
|
|
|
|
|
|
2019-05-30 20:57:18 +00:00
|
|
|
@with_all_phases
|
2019-05-23 21:32:21 +00:00
|
|
|
@spec_state_test
|
2019-05-30 20:57:18 +00:00
|
|
|
def test_slots_2(spec, state):
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'pre', state
|
|
|
|
slots = 2
|
|
|
|
yield 'slots', slots
|
2019-05-30 20:57:18 +00:00
|
|
|
spec.process_slots(state, state.slot + slots)
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'post', state
|
|
|
|
|
|
|
|
|
2019-05-30 20:57:18 +00:00
|
|
|
@with_all_phases
|
2019-05-23 21:32:21 +00:00
|
|
|
@spec_state_test
|
2019-05-30 20:57:18 +00:00
|
|
|
def test_empty_epoch(spec, state):
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'pre', state
|
|
|
|
slots = spec.SLOTS_PER_EPOCH
|
|
|
|
yield 'slots', slots
|
2019-05-30 20:57:18 +00:00
|
|
|
spec.process_slots(state, state.slot + slots)
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'post', state
|
|
|
|
|
|
|
|
|
2019-05-30 20:57:18 +00:00
|
|
|
@with_all_phases
|
2019-05-23 21:32:21 +00:00
|
|
|
@spec_state_test
|
2019-05-30 20:57:18 +00:00
|
|
|
def test_double_empty_epoch(spec, state):
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'pre', state
|
|
|
|
slots = spec.SLOTS_PER_EPOCH * 2
|
|
|
|
yield 'slots', slots
|
2019-05-30 20:57:18 +00:00
|
|
|
spec.process_slots(state, state.slot + slots)
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'post', state
|
|
|
|
|
|
|
|
|
2019-05-30 20:57:18 +00:00
|
|
|
@with_all_phases
|
2019-05-23 21:32:21 +00:00
|
|
|
@spec_state_test
|
2019-05-30 20:57:18 +00:00
|
|
|
def test_over_epoch_boundary(spec, state):
|
|
|
|
spec.process_slots(state, state.slot + (spec.SLOTS_PER_EPOCH // 2))
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'pre', state
|
|
|
|
slots = spec.SLOTS_PER_EPOCH
|
|
|
|
yield 'slots', slots
|
2019-05-30 20:57:18 +00:00
|
|
|
spec.process_slots(state, state.slot + slots)
|
2019-05-23 21:32:21 +00:00
|
|
|
yield 'post', state
|