Move `get_state_root` to `pyspec/tests/helpers.py`

This commit is contained in:
Hsiao-Wei Wang 2019-05-01 17:06:02 +08:00
parent b6b4d3cbaf
commit 5f341ae493
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 9 additions and 8 deletions

View File

@ -410,3 +410,11 @@ def next_epoch(state):
block = build_empty_block_for_next_slot(state)
block.slot += spec.SLOTS_PER_EPOCH - (state.slot % spec.SLOTS_PER_EPOCH)
state_transition(state, block)
def get_state_root(state, slot) -> bytes:
"""
Return the state root at a recent ``slot``.
"""
assert slot < state.slot <= slot + spec.SLOTS_PER_HISTORICAL_ROOT
return state.latest_state_roots[slot % spec.SLOTS_PER_HISTORICAL_ROOT]

View File

@ -38,6 +38,7 @@ from .helpers import (
build_deposit_data,
build_empty_block_for_next_slot,
fill_aggregate_attestation,
get_state_root,
get_valid_attestation,
get_valid_attester_slashing,
get_valid_proposer_slashing,
@ -51,14 +52,6 @@ from .helpers import (
pytestmark = pytest.mark.sanity
def get_state_root(state, slot) -> bytes:
"""
Return the state root at a recent ``slot``.
"""
assert slot < state.slot <= slot + SLOTS_PER_HISTORICAL_ROOT
return state.latest_state_roots[slot % SLOTS_PER_HISTORICAL_ROOT]
def test_slot_transition(state):
test_state = deepcopy(state)
cache_state(test_state)