@@ -658,6 +658,8 @@ def test_insufficient_effective_balance(spec, state):
658658 state .validators [
659659 validator_index
660660 ].effective_balance -= spec .EFFECTIVE_BALANCE_INCREMENT
661+ # Make sure validator has enough balance to withdraw
662+ state .balances [validator_index ] += spec .EFFECTIVE_BALANCE_INCREMENT
661663
662664 set_compounding_withdrawal_credential (spec , state , validator_index , address = address )
663665 withdrawal_request = spec .WithdrawalRequest (
@@ -787,6 +789,30 @@ def test_partial_withdrawal_activation_epoch_less_than_shard_committee_period(
787789 )
788790
789791
792+ def test_insufficient_balance (spec , state ):
793+ rng = random .Random (1361 )
794+ state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
795+ current_epoch = spec .get_current_epoch (state )
796+ validator_index = rng .choice (spec .get_active_validator_indices (state , current_epoch ))
797+ validator_pubkey = state .validators [validator_index ].pubkey
798+ address = b"\x22 " * 20
799+ amount = spec .EFFECTIVE_BALANCE_INCREMENT
800+
801+ # Validator will not be able to partial withdrawal because MIN_ACTIVATION_BALANCE + amount > balance
802+ set_compounding_withdrawal_credential (spec , state , validator_index , address = address )
803+ withdrawal_request = spec .WithdrawalRequest (
804+ source_address = address ,
805+ validator_pubkey = validator_pubkey ,
806+ amount = amount ,
807+ )
808+
809+ yield from run_withdrawal_request_processing (
810+ spec ,
811+ state ,
812+ withdrawal_request ,
813+ success = False ,
814+ )
815+
790816#
791817# Run processing
792818#
0 commit comments