From aa91788dfbeeb79c8f38a68e3ee610ce11357fde Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 15 Oct 2021 19:46:46 +0100 Subject: [PATCH] Yield the `pre` state for this test type before making blocks --- .../eth2spec/test/helpers/fork_transition.py | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py b/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py index 947954b80..fbed08f09 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py +++ b/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py @@ -244,15 +244,6 @@ def run_transition_with_operation(state, signed_exits = prepare_signed_exits(spec, state, [selected_validator_index]) operation_dict = {'voluntary_exits': signed_exits} - blocks = [] - - if is_right_before_fork: - # add a block with operation. - block = build_empty_block_for_next_slot(spec, state) - _set_operations_by_dict(block, operation_dict) - signed_block = state_transition_and_sign_block(spec, state, block) - blocks.append(pre_tag(signed_block)) - def _check_state(): if operation_type == OperationType.PROPOSER_SLASHING: slashed_proposer = state.validators[proposer_slashing.signed_header_1.message.proposer_index] @@ -274,11 +265,19 @@ def run_transition_with_operation(state, validator = state.validators[selected_validator_index] assert validator.exit_epoch < post_spec.FAR_FUTURE_EPOCH - if is_right_before_fork: - _check_state() - yield "pre", state + blocks = [] + + if is_right_before_fork: + # add a block with operation. + block = build_empty_block_for_next_slot(spec, state) + _set_operations_by_dict(block, operation_dict) + signed_block = state_transition_and_sign_block(spec, state, block) + blocks.append(pre_tag(signed_block)) + + _check_state() + # irregular state transition to handle fork: _operation_at_slot = operation_dict if is_at_fork else None state, block = do_altair_fork(state, spec, post_spec, fork_epoch, operation_dict=_operation_at_slot)