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: else:
false false
else: else:
# Skip all other per-slot processing. Move directly to epoch processing # Skip all per-block processing. Move directly to epoch processing
# prison. Do not do any slot updates when passing go. # prison. Do not do any block updates when passing go.
true true
# Heavy updates that happen for every epoch - these never fail (or so we hope) # Heavy updates that happen for every epoch - these never fail (or so we hope)

View File

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