@@ -789,6 +789,8 @@ def test_partial_withdrawal_activation_epoch_less_than_shard_committee_period(
789789 )
790790
791791
792+ @with_electra_and_later
793+ @spec_state_test
792794def test_insufficient_balance (spec , state ):
793795 rng = random .Random (1361 )
794796 state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
@@ -813,6 +815,41 @@ def test_insufficient_balance(spec, state):
813815 success = False ,
814816 )
815817
818+
819+ @with_electra_and_later
820+ @spec_state_test
821+ def test_full_exit_request_has_partial_withdrawal (spec , state ):
822+ rng = random .Random (1361 )
823+ # Move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
824+ state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
825+
826+ current_epoch = spec .get_current_epoch (state )
827+ validator_index = rng .choice (spec .get_active_validator_indices (state , current_epoch ))
828+ validator_pubkey = state .validators [validator_index ].pubkey
829+ address = b"\x22 " * 20
830+ set_eth1_withdrawal_credential_with_balance (
831+ spec , state , validator_index , address = address
832+ )
833+ withdrawal_request = spec .WithdrawalRequest (
834+ source_address = address ,
835+ validator_pubkey = validator_pubkey ,
836+ amount = spec .FULL_EXIT_REQUEST_AMOUNT ,
837+ )
838+
839+ # Validator can only be exited if there's no pending partial withdrawals in state
840+ state .balances [validator_index ] = spec .MAX_EFFECTIVE_BALANCE_ELECTRA
841+ state .pending_partial_withdrawals .append (
842+ spec .PendingPartialWithdrawal (
843+ index = validator_index ,
844+ amount = 1 ,
845+ withdrawable_epoch = spec .compute_activation_exit_epoch (current_epoch ),
846+ )
847+ )
848+
849+ yield from run_withdrawal_request_processing (
850+ spec , state , withdrawal_request , success = False
851+ )
852+
816853#
817854# Run processing
818855#
0 commit comments