diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py index b12438d0d1..b05c20f565 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_consolidation_request.py @@ -421,6 +421,9 @@ def test_incorrect_source_equals_target(spec, state): target_pubkey=state.validators[source_index].pubkey, ) + # Check the the return condition + assert consolidation.source_pubkey == consolidation.target_pubkey + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -454,6 +457,9 @@ def test_incorrect_exceed_pending_consolidations_limit(spec, state): ) set_eth1_withdrawal_credential_with_balance(spec, state, target_index) + # Check the the return condition + assert len(state.pending_consolidations) == spec.PENDING_CONSOLIDATIONS_LIMIT + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -463,7 +469,6 @@ def test_incorrect_exceed_pending_consolidations_limit(spec, state): @spec_state_test @single_phase def test_incorrect_not_enough_consolidation_churn_available(spec, state): - state.validators = state.validators[0:2] state.pending_consolidations = [ spec.PendingConsolidation(source_index=0, target_index=1) ] @@ -481,7 +486,12 @@ def test_incorrect_not_enough_consolidation_churn_available(spec, state): source_pubkey=state.validators[source_index].pubkey, target_pubkey=state.validators[target_index].pubkey, ) + set_eth1_withdrawal_credential_with_balance(spec, state, target_index) + + # Check the the return condition + assert spec.get_consolidation_churn_limit(state) <= spec.MIN_ACTIVATION_BALANCE + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -514,6 +524,9 @@ def test_incorrect_exited_source(spec, state): # exit source spec.initiate_validator_exit(state, source_index) + # Check the the return condition + assert state.validators[source_index].exit_epoch != spec.FAR_FUTURE_EPOCH + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -544,6 +557,10 @@ def test_incorrect_exited_target(spec, state): set_eth1_withdrawal_credential_with_balance(spec, state, target_index) # exit target spec.initiate_validator_exit(state, 1) + + # Check the the return condition + assert state.validators[target_index].exit_epoch != spec.FAR_FUTURE_EPOCH + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -576,6 +593,9 @@ def test_incorrect_inactive_source(spec, state): # set source validator as not yet activated state.validators[source_index].activation_epoch = spec.FAR_FUTURE_EPOCH + # Check the the return condition + assert not spec.is_active_validator(state.validators[source_index], current_epoch) + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -607,6 +627,10 @@ def test_incorrect_inactive_target(spec, state): # set target validator as not yet activated state.validators[1].activation_epoch = spec.FAR_FUTURE_EPOCH + + # Check the the return condition + assert not spec.is_active_validator(state.validators[target_index], current_epoch) + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -633,6 +657,10 @@ def test_incorrect_no_source_execution_withdrawal_credential(spec, state): target_pubkey=state.validators[target_index].pubkey, ) set_eth1_withdrawal_credential_with_balance(spec, state, target_index) + + # Check the the return condition + assert not spec.has_execution_withdrawal_credential(state.validators[source_index]) + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -661,6 +689,10 @@ def test_incorrect_no_target_execution_withdrawal_credential(spec, state): source_pubkey=state.validators[source_index].pubkey, target_pubkey=state.validators[target_index].pubkey, ) + + # Check the the return condition + assert not spec.has_execution_withdrawal_credential(state.validators[target_index]) + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -691,6 +723,9 @@ def test_incorrect_incorrect_source_address(spec, state): ) set_eth1_withdrawal_credential_with_balance(spec, state, target_index) + # Check the the return condition + assert not state.validators[source_index].withdrawal_credentials[12:] == consolidation.source_address + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -721,6 +756,9 @@ def test_incorrect_unknown_source_pubkey(spec, state): ) set_eth1_withdrawal_credential_with_balance(spec, state, target_index) + # Check the the return condition + assert not state.validators[source_index].pubkey == consolidation.source_pubkey + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -751,6 +789,9 @@ def test_incorrect_unknown_target_pubkey(spec, state): ) set_eth1_withdrawal_credential_with_balance(spec, state, target_index) + # Check the the return condition + assert not state.validators[target_index].pubkey == consolidation.target_pubkey + yield from run_consolidation_processing( spec, state, consolidation, success=False ) @@ -762,7 +803,7 @@ def run_consolidation_processing(spec, state, consolidation, success=True): - pre-state ('pre') - consolidation_request ('consolidation_request') - post-state ('post'). - If ``valid == False``, run expecting ``AssertionError`` + If ``success == False``, ``process_consolidation_request`` would return without any state change. """ if success: