### Question:
CheckpointStateTask implements CacheableTask<Checkpoint, BeaconState> { @Override public Stream<Checkpoint> streamIntermediateSteps() { if (checkpoint.getEpoch().equals(UInt64.ZERO)) { return Stream.empty(); } return Stream.iterate( checkpoint.getEpoch().minus(1), current -> current != null && current.isGreaterThanOrEqualTo(UInt64.ZERO) && current .plus(INTERIM_EPOCHS_TO_SEARCH) .isGreaterThanOrEqualTo(checkpoint.getEpoch()), current -> current.equals(UInt64.ZERO) ? null : current.minus(1)) .map(epoch -> new Checkpoint(epoch, checkpoint.getRoot())); } CheckpointStateTask(final Checkpoint checkpoint, final AsyncStateProvider stateProvider); private  CheckpointStateTask(
      final Checkpoint checkpoint,
      final AsyncStateProvider stateProvider,
      final BeaconState baseState); @Override Checkpoint getKey(); @Override Stream<Checkpoint> streamIntermediateSteps(); @Override CacheableTask<Checkpoint, BeaconState> rebase(final BeaconState newBaseValue); @Override SafeFuture<Optional<BeaconState>> performTask();  }### Answer:
@Test void streamIntermediateSteps_shouldIncludeCheckpointsFromPreviousEpochs() { final Bytes32 root = Bytes32.fromHexStringLenient("0x1234"); final List<Checkpoint> expected = new ArrayList<>(); final UInt64 epoch = UInt64.valueOf(50); for (int i = epoch.intValue() - 1; i >= 30; i--) { expected.add(new Checkpoint(UInt64.valueOf(i), root)); } assertThat(createTask(epoch, root).streamIntermediateSteps()) .containsExactlyElementsOf(expected); }
@Test void streamIntermediateSteps_shouldStopAtEpochZero() { final Bytes32 root = Bytes32.fromHexStringLenient("0x1234"); final List<Checkpoint> expected = new ArrayList<>(); final UInt64 epoch = UInt64.valueOf(5); for (int i = epoch.intValue() - 1; i >= 0; i--) { expected.add(new Checkpoint(UInt64.valueOf(i), root)); } assertThat(createTask(epoch, root).streamIntermediateSteps()) .containsExactlyElementsOf(expected); }