17
17
get_domain ,
18
18
)
19
19
from eth .beacon .deposit_helpers import (
20
+ min_empty_validator_index ,
20
21
process_deposit ,
21
22
validate_proof_of_possession ,
22
23
)
23
24
from eth .beacon .types .states import BeaconState
24
25
from eth .beacon .types .deposit_input import DepositInput
26
+ from eth .beacon .types .validator_records import ValidatorRecord
25
27
26
28
27
29
def sign_proof_of_possession (deposit_input , privkey , domain ):
@@ -37,6 +39,41 @@ def make_deposit_input(pubkey, withdrawal_credentials, randao_commitment):
37
39
)
38
40
39
41
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
+
40
77
@pytest .mark .parametrize (
41
78
"expected" ,
42
79
(
0 commit comments