simplify randao layers tests

This commit is contained in:
Danny Ryan 2018-12-14 17:14:05 -06:00 committed by zah
parent b1114a94de
commit aa5129b90e
2 changed files with 9 additions and 8 deletions

View File

@ -787,8 +787,8 @@ proc updateState*(state: BeaconState, latest_block: BeaconBlock,
else:
false
else:
# Skip all other per-slot processing. Move directly to epoch processing
# prison. Do not do any slot updates when passing go.
# Skip all per-block processing. Move directly to epoch processing
# prison. Do not do any block updates when passing go.
true
# Heavy updates that happen for every epoch - these never fail (or so we hope)

View File

@ -71,12 +71,13 @@ suite "Block processing":
let
state = on_startup(makeInitialDeposits(), 0, Eth2Digest())
latest_block = makeGenesisBlock(state)
expected_proposer_index = get_beacon_proposer_index(state, state.slot + 1)
previous_randao_layers = state.validator_registry[expected_proposer_index].randao_layers
proposer_index = get_beacon_proposer_index(state, state.slot + 1)
previous_randao_layers = state.validator_registry[proposer_index].randao_layers
new_state = updateState(state, latest_block, none(BeaconBlock))
updated_proposer = new_state.state.validator_registry[proposer_index]
check:
new_state.state.validator_registry[expected_proposer_index].randao_layers ==
previous_randao_layers + 1
updated_proposer.randao_layers == previous_randao_layers + 1
test "Proposer randao layers unchanged, empty block":
let
@ -86,7 +87,7 @@ suite "Block processing":
previous_randao_layers = state.validator_registry[proposer_index].randao_layers
new_block = makeBlock(state, latest_block)
new_state = updateState(state, latest_block, some(new_block))
updated_proposer = new_state.state.validator_registry[proposer_index]
check:
new_state.state.validator_registry[proposer_index].randao_layers ==
previous_randao_layers
updated_proposer.randao_layers == previous_randao_layers