Beispiel #1
0
def test_get_active_validator_indices(sample_validator_record_params):
    # 3 validators are ACTIVE
    validators = [
        ValidatorRecord(
            **sample_validator_record_params,
        ).copy(
            status=ValidatorStatusCode.ACTIVE,
        )
        for i in range(3)
    ]
    active_validator_indices = get_active_validator_indices(validators)
    assert len(active_validator_indices) == 3

    # Make one validator becomes ACTIVE_PENDING_EXIT.
    validators[0] = validators[0].copy(
        status=ValidatorStatusCode.ACTIVE_PENDING_EXIT,
    )
    active_validator_indices = get_active_validator_indices(validators)
    assert len(active_validator_indices) == 3

    # Make one validator becomes EXITED_WITHOUT_PENALTY.
    validators[0] = validators[0].copy(
        status=ValidatorStatusCode.EXITED_WITHOUT_PENALTY,
    )
    active_validator_indices = get_active_validator_indices(validators)
    assert len(active_validator_indices) == 2
Beispiel #2
0
def test_get_active_validator_indices(sample_validator_record_params):
    current_slot = 1
    # 3 validators are ACTIVE
    validators = [
        ValidatorRecord(**sample_validator_record_params, ).copy(
            activation_slot=0,
            exit_slot=FAR_FUTURE_SLOT,
        ) for i in range(3)
    ]
    active_validator_indices = get_active_validator_indices(
        validators, current_slot)
    assert len(active_validator_indices) == 3

    validators[0] = validators[0].copy(
        activation_slot=current_slot + 1,  # activation_slot > current_slot
    )
    active_validator_indices = get_active_validator_indices(
        validators, current_slot)
    assert len(active_validator_indices) == 2
Beispiel #3
0
 def active_validator_indices(self) -> Tuple[int]:
     return get_active_validator_indices(self.current_dynasty,
                                         self.validators)