@@ -442,3 +442,162 @@ def test_pending_withdrawals_at_max_mixed_with_sweep_and_fully_withdrawable(spec
442
442
443
443
withdrawals_exceeding_max = pending_withdrawal_requests [spec .MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP :]
444
444
assert state .pending_partial_withdrawals == withdrawals_exceeding_max
445
+
446
+
447
+ @with_electra_and_later
448
+ @spec_state_test
449
+ def test_partially_withdrawable_validator_compounding_max_plus_one (spec , state ):
450
+ """Test compounding validator with balance just above MAX_EFFECTIVE_BALANCE_ELECTRA"""
451
+ validator_index = 0
452
+ set_compounding_withdrawal_credential_with_balance (
453
+ spec , state ,
454
+ validator_index ,
455
+ balance = spec .MAX_EFFECTIVE_BALANCE_ELECTRA + 1
456
+ )
457
+ assert spec .is_partially_withdrawable_validator (
458
+ state .validators [validator_index ],
459
+ state .balances [validator_index ]
460
+ )
461
+
462
+ next_slot (spec , state )
463
+ execution_payload = build_empty_execution_payload (spec , state )
464
+ yield from run_withdrawals_processing (
465
+ spec , state ,
466
+ execution_payload ,
467
+ fully_withdrawable_indices = [],
468
+ partial_withdrawals_indices = [validator_index ]
469
+ )
470
+ assert state .pending_partial_withdrawals == []
471
+
472
+
473
+ @with_electra_and_later
474
+ @spec_state_test
475
+ def test_partially_withdrawable_validator_compounding_exact_max (spec , state ):
476
+ """Test compounding validator with balance exactly equal to MAX_EFFECTIVE_BALANCE_ELECTRA"""
477
+ validator_index = 0
478
+ set_compounding_withdrawal_credential_with_balance (
479
+ spec , state ,
480
+ validator_index
481
+ )
482
+ assert not spec .is_partially_withdrawable_validator (
483
+ state .validators [validator_index ],
484
+ state .balances [validator_index ]
485
+ )
486
+
487
+ next_slot (spec , state )
488
+ execution_payload = build_empty_execution_payload (spec , state )
489
+ yield from run_withdrawals_processing (
490
+ spec , state ,
491
+ execution_payload ,
492
+ fully_withdrawable_indices = [],
493
+ partial_withdrawals_indices = []
494
+ )
495
+ assert state .pending_partial_withdrawals == []
496
+
497
+
498
+ @with_electra_and_later
499
+ @spec_state_test
500
+ def test_partially_withdrawable_validator_compounding_max_minus_one (spec , state ):
501
+ """Test compounding validator whose balance is just below MAX_EFFECTIVE_BALANCE_ELECTRA"""
502
+ validator_index = 0
503
+ set_compounding_withdrawal_credential_with_balance (
504
+ spec , state ,
505
+ validator_index ,
506
+ effective_balance = spec .MAX_EFFECTIVE_BALANCE_ELECTRA - spec .EFFECTIVE_BALANCE_INCREMENT ,
507
+ balance = spec .MAX_EFFECTIVE_BALANCE_ELECTRA - 1
508
+ )
509
+ assert not spec .is_partially_withdrawable_validator (
510
+ state .validators [validator_index ],
511
+ state .balances [validator_index ]
512
+ )
513
+
514
+ next_slot (spec , state )
515
+ execution_payload = build_empty_execution_payload (spec , state )
516
+ yield from run_withdrawals_processing (
517
+ spec , state ,
518
+ execution_payload ,
519
+ fully_withdrawable_indices = [],
520
+ partial_withdrawals_indices = []
521
+ )
522
+ assert state .pending_partial_withdrawals == []
523
+
524
+
525
+ @with_electra_and_later
526
+ @spec_state_test
527
+ def test_partially_withdrawable_validator_compounding_min_plus_one (spec , state ):
528
+ """Test compounding validator just above MIN_ACTIVATION_BALANCE"""
529
+ validator_index = 0
530
+ set_compounding_withdrawal_credential_with_balance (
531
+ spec , state ,
532
+ validator_index ,
533
+ effective_balance = spec .MIN_ACTIVATION_BALANCE ,
534
+ balance = spec .MIN_ACTIVATION_BALANCE + 1
535
+ )
536
+ assert not spec .is_partially_withdrawable_validator (
537
+ state .validators [validator_index ],
538
+ state .balances [validator_index ]
539
+ )
540
+
541
+ next_slot (spec , state )
542
+ execution_payload = build_empty_execution_payload (spec , state )
543
+ yield from run_withdrawals_processing (
544
+ spec , state ,
545
+ execution_payload ,
546
+ fully_withdrawable_indices = [],
547
+ partial_withdrawals_indices = []
548
+ )
549
+ assert state .pending_partial_withdrawals == []
550
+
551
+
552
+ @with_electra_and_later
553
+ @spec_state_test
554
+ def test_partially_withdrawable_validator_compounding_exact_min (spec , state ):
555
+ """Test compounding validator with balance exactly equal to MIN_ACTIVATION_BALANCE"""
556
+ validator_index = 0
557
+ set_compounding_withdrawal_credential_with_balance (
558
+ spec , state ,
559
+ validator_index ,
560
+ effective_balance = spec .MIN_ACTIVATION_BALANCE ,
561
+ balance = spec .MIN_ACTIVATION_BALANCE
562
+ )
563
+ assert not spec .is_partially_withdrawable_validator (
564
+ state .validators [validator_index ],
565
+ state .balances [validator_index ]
566
+ )
567
+
568
+ next_slot (spec , state )
569
+ execution_payload = build_empty_execution_payload (spec , state )
570
+ yield from run_withdrawals_processing (
571
+ spec , state ,
572
+ execution_payload ,
573
+ fully_withdrawable_indices = [],
574
+ partial_withdrawals_indices = []
575
+ )
576
+ assert state .pending_partial_withdrawals == []
577
+
578
+
579
+ @with_electra_and_later
580
+ @spec_state_test
581
+ def test_partially_withdrawable_validator_compounding_min_minus_one (spec , state ):
582
+ """Test compounding validator below MIN_ACTIVATION_BALANCE"""
583
+ validator_index = 0
584
+ set_compounding_withdrawal_credential_with_balance (
585
+ spec , state ,
586
+ validator_index ,
587
+ effective_balance = spec .MIN_ACTIVATION_BALANCE - spec .EFFECTIVE_BALANCE_INCREMENT ,
588
+ balance = spec .MIN_ACTIVATION_BALANCE - 1
589
+ )
590
+ assert not spec .is_partially_withdrawable_validator (
591
+ state .validators [validator_index ],
592
+ state .balances [validator_index ]
593
+ )
594
+
595
+ next_slot (spec , state )
596
+ execution_payload = build_empty_execution_payload (spec , state )
597
+ yield from run_withdrawals_processing (
598
+ spec , state ,
599
+ execution_payload ,
600
+ fully_withdrawable_indices = [],
601
+ partial_withdrawals_indices = []
602
+ )
603
+ assert state .pending_partial_withdrawals == []
0 commit comments