@Test void activeValidators_retrievesCorrectValue() { final UInt64 slotNumber = compute_start_slot_at_epoch(UInt64.valueOf(13)); when(state.getSlot()).thenReturn(slotNumber); final List<Validator> validators = List.of( validator(13, 15, false), validator(14, 15, false), validator(10, 12, false), validator(10, 15, true)); when(recentChainData.getBestState()).thenReturn(Optional.of(state)); when(state.getCurrent_epoch_attestations()).thenReturn(SSZList.empty(PendingAttestation.class)); when(state.getPrevious_epoch_attestations()) .thenReturn(SSZList.empty(PendingAttestation.class)); when(state.getValidators()).thenReturn(SSZList.createMutable(validators, 100, Validator.class)); beaconChainMetrics.onSlot(slotNumber); assertThat(metricsSystem.getGauge(BEACON, "current_active_validators").getValue()).isEqualTo(2); assertThat(metricsSystem.getGauge(BEACON, "previous_active_validators").getValue()) .isEqualTo(1); }
@Override public void onSlot(final UInt64 slot) { recentChainData.getBestState().ifPresent(this::updateMetrics); }
BeaconChainMetrics implements SlotEventsChannel { @Override public void onSlot(final UInt64 slot) { recentChainData.getBestState().ifPresent(this::updateMetrics); } }
BeaconChainMetrics implements SlotEventsChannel { @Override public void onSlot(final UInt64 slot) { recentChainData.getBestState().ifPresent(this::updateMetrics); } BeaconChainMetrics(
      final RecentChainData recentChainData,
      final NodeSlot nodeSlot,
      final MetricsSystem metricsSystem,
      final Eth2Network p2pNetwork); }
BeaconChainMetrics implements SlotEventsChannel { @Override public void onSlot(final UInt64 slot) { recentChainData.getBestState().ifPresent(this::updateMetrics); } BeaconChainMetrics(
      final RecentChainData recentChainData,
      final NodeSlot nodeSlot,
      final MetricsSystem metricsSystem,
      final Eth2Network p2pNetwork); @Override void onSlot(final UInt64 slot); }
BeaconChainMetrics implements SlotEventsChannel { @Override public void onSlot(final UInt64 slot) { recentChainData.getBestState().ifPresent(this::updateMetrics); } BeaconChainMetrics(
      final RecentChainData recentChainData,
      final NodeSlot nodeSlot,
      final MetricsSystem metricsSystem,
      final Eth2Network p2pNetwork); @Override void onSlot(final UInt64 slot);  }