@Test void status_shouldBePendingInitialised() { final Validator validator = pendingValidator(TWO_HUNDRED, FAR_FUTURE_EPOCH); assertThat(ValidatorResponse.getValidatorStatus(ONE_HUNDRED, validator)) .isEqualTo(ValidatorStatus.pending_initialized); }
static ValidatorStatus getValidatorStatus( final UInt64 epoch, final tech.pegasys.teku.datastructures.state.Validator validator) { if (validator.getActivation_epoch().isGreaterThan(epoch)) { return validator.getActivation_eligibility_epoch().equals(FAR_FUTURE_EPOCH) ? ValidatorStatus.pending_initialized : ValidatorStatus.pending_queued; } if (validator.getActivation_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getExit_epoch())) { if (validator.getExit_epoch().equals(FAR_FUTURE_EPOCH)) { return ValidatorStatus.active_ongoing; } return validator.isSlashed() ? ValidatorStatus.active_slashed : ValidatorStatus.active_exiting; } if (validator.getExit_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getWithdrawable_epoch())) { return validator.isSlashed() ? ValidatorStatus.exited_slashed : ValidatorStatus.exited_unslashed; } if (validator.getWithdrawable_epoch().isLessThanOrEqualTo(epoch)) { return validator.getEffective_balance().isGreaterThan(UInt64.ZERO) ? ValidatorStatus.withdrawal_possible : ValidatorStatus.withdrawal_done; } throw new IllegalStateException("Unable to determine validator status"); }
ValidatorResponse { static ValidatorStatus getValidatorStatus( final UInt64 epoch, final tech.pegasys.teku.datastructures.state.Validator validator) { if (validator.getActivation_epoch().isGreaterThan(epoch)) { return validator.getActivation_eligibility_epoch().equals(FAR_FUTURE_EPOCH) ? ValidatorStatus.pending_initialized : ValidatorStatus.pending_queued; } if (validator.getActivation_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getExit_epoch())) { if (validator.getExit_epoch().equals(FAR_FUTURE_EPOCH)) { return ValidatorStatus.active_ongoing; } return validator.isSlashed() ? ValidatorStatus.active_slashed : ValidatorStatus.active_exiting; } if (validator.getExit_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getWithdrawable_epoch())) { return validator.isSlashed() ? ValidatorStatus.exited_slashed : ValidatorStatus.exited_unslashed; } if (validator.getWithdrawable_epoch().isLessThanOrEqualTo(epoch)) { return validator.getEffective_balance().isGreaterThan(UInt64.ZERO) ? ValidatorStatus.withdrawal_possible : ValidatorStatus.withdrawal_done; } throw new IllegalStateException("Unable to determine validator status"); } }
ValidatorResponse { static ValidatorStatus getValidatorStatus( final UInt64 epoch, final tech.pegasys.teku.datastructures.state.Validator validator) { if (validator.getActivation_epoch().isGreaterThan(epoch)) { return validator.getActivation_eligibility_epoch().equals(FAR_FUTURE_EPOCH) ? ValidatorStatus.pending_initialized : ValidatorStatus.pending_queued; } if (validator.getActivation_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getExit_epoch())) { if (validator.getExit_epoch().equals(FAR_FUTURE_EPOCH)) { return ValidatorStatus.active_ongoing; } return validator.isSlashed() ? ValidatorStatus.active_slashed : ValidatorStatus.active_exiting; } if (validator.getExit_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getWithdrawable_epoch())) { return validator.isSlashed() ? ValidatorStatus.exited_slashed : ValidatorStatus.exited_unslashed; } if (validator.getWithdrawable_epoch().isLessThanOrEqualTo(epoch)) { return validator.getEffective_balance().isGreaterThan(UInt64.ZERO) ? ValidatorStatus.withdrawal_possible : ValidatorStatus.withdrawal_done; } throw new IllegalStateException("Unable to determine validator status"); } @JsonCreator  ValidatorResponse(
      @JsonProperty("index") final UInt64 index,
      @JsonProperty("balance") final UInt64 balance,
      @JsonProperty("status") final ValidatorStatus status,
      @JsonProperty("validator") final Validator validator); }
ValidatorResponse { static ValidatorStatus getValidatorStatus( final UInt64 epoch, final tech.pegasys.teku.datastructures.state.Validator validator) { if (validator.getActivation_epoch().isGreaterThan(epoch)) { return validator.getActivation_eligibility_epoch().equals(FAR_FUTURE_EPOCH) ? ValidatorStatus.pending_initialized : ValidatorStatus.pending_queued; } if (validator.getActivation_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getExit_epoch())) { if (validator.getExit_epoch().equals(FAR_FUTURE_EPOCH)) { return ValidatorStatus.active_ongoing; } return validator.isSlashed() ? ValidatorStatus.active_slashed : ValidatorStatus.active_exiting; } if (validator.getExit_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getWithdrawable_epoch())) { return validator.isSlashed() ? ValidatorStatus.exited_slashed : ValidatorStatus.exited_unslashed; } if (validator.getWithdrawable_epoch().isLessThanOrEqualTo(epoch)) { return validator.getEffective_balance().isGreaterThan(UInt64.ZERO) ? ValidatorStatus.withdrawal_possible : ValidatorStatus.withdrawal_done; } throw new IllegalStateException("Unable to determine validator status"); } @JsonCreator  ValidatorResponse(
      @JsonProperty("index") final UInt64 index,
      @JsonProperty("balance") final UInt64 balance,
      @JsonProperty("status") final ValidatorStatus status,
      @JsonProperty("validator") final Validator validator); static ValidatorResponse fromState(final BeaconState state, final Integer index); @Override boolean equals(final Object o); @Override int hashCode(); }
ValidatorResponse { static ValidatorStatus getValidatorStatus( final UInt64 epoch, final tech.pegasys.teku.datastructures.state.Validator validator) { if (validator.getActivation_epoch().isGreaterThan(epoch)) { return validator.getActivation_eligibility_epoch().equals(FAR_FUTURE_EPOCH) ? ValidatorStatus.pending_initialized : ValidatorStatus.pending_queued; } if (validator.getActivation_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getExit_epoch())) { if (validator.getExit_epoch().equals(FAR_FUTURE_EPOCH)) { return ValidatorStatus.active_ongoing; } return validator.isSlashed() ? ValidatorStatus.active_slashed : ValidatorStatus.active_exiting; } if (validator.getExit_epoch().isLessThanOrEqualTo(epoch) && epoch.isLessThan(validator.getWithdrawable_epoch())) { return validator.isSlashed() ? ValidatorStatus.exited_slashed : ValidatorStatus.exited_unslashed; } if (validator.getWithdrawable_epoch().isLessThanOrEqualTo(epoch)) { return validator.getEffective_balance().isGreaterThan(UInt64.ZERO) ? ValidatorStatus.withdrawal_possible : ValidatorStatus.withdrawal_done; } throw new IllegalStateException("Unable to determine validator status"); } @JsonCreator  ValidatorResponse(
      @JsonProperty("index") final UInt64 index,
      @JsonProperty("balance") final UInt64 balance,
      @JsonProperty("status") final ValidatorStatus status,
      @JsonProperty("validator") final Validator validator); static ValidatorResponse fromState(final BeaconState state, final Integer index); @Override boolean equals(final Object o); @Override int hashCode(); @JsonProperty("index")
  @Schema(
      type = "string",
      example = EXAMPLE_UINT64,
      description = "Index of validator in validator registry.")
  final UInt64 index; @JsonProperty("balance")
  @Schema(
      type = "string",
      example = EXAMPLE_UINT64,
      description = "Current validator balance in gwei.")
  final UInt64 balance; @JsonProperty("status")
  final ValidatorStatus status; @JsonProperty("validator")
  final Validator validator; }