1717 get_domain ,
1818)
1919from eth .beacon .deposit_helpers import (
20+ min_empty_validator_index ,
2021 process_deposit ,
2122 validate_proof_of_possession ,
2223)
2324from eth .beacon .types .states import BeaconState
2425from eth .beacon .types .deposit_input import DepositInput
26+ from eth .beacon .types .validator_records import ValidatorRecord
2527
2628
2729def sign_proof_of_possession (deposit_input , privkey , domain ):
@@ -37,6 +39,41 @@ def make_deposit_input(pubkey, withdrawal_credentials, randao_commitment):
3739 )
3840
3941
42+ @pytest .mark .parametrize (
43+ "balance,"
44+ "latest_status_change_slot,"
45+ "zero_balance_validator_ttl,"
46+ "current_slot,"
47+ "expected" ,
48+ (
49+ (0 , 1 , 1 , 2 , 0 ),
50+ (1 , 1 , 1 , 2 , None ), # not (balance == 0)
51+ (0 , 1 , 1 , 1 , None ), # not (validator.latest_status_change_slot + zero_balance_validator_ttl <= current_slot) # noqa: E501
52+ ),
53+ )
54+ def test_min_empty_validator_index (sample_validator_record_params ,
55+ balance ,
56+ latest_status_change_slot ,
57+ zero_balance_validator_ttl ,
58+ current_slot ,
59+ expected ):
60+ validators = [
61+ ValidatorRecord (** sample_validator_record_params ).copy (
62+ balance = balance ,
63+ latest_status_change_slot = latest_status_change_slot ,
64+ )
65+ for _ in range (10 )
66+ ]
67+
68+ result = min_empty_validator_index (
69+ validators = validators ,
70+ current_slot = current_slot ,
71+ zero_balance_validator_ttl = zero_balance_validator_ttl ,
72+ )
73+
74+ assert result == expected
75+
76+
4077@pytest .mark .parametrize (
4178 "expected" ,
4279 (
0 commit comments