### Question:
FastSyncActions { public CompletableFuture<FastSyncState> downloadPivotBlockHeader( final FastSyncState currentState) { if (currentState.getPivotBlockHeader().isPresent()) { return completedFuture(currentState); } return new PivotBlockRetriever( protocolSchedule, ethContext, metricsSystem, currentState.getPivotBlockNumber().getAsLong(), syncConfig.getFastSyncMinimumPeerCount(), syncConfig.getFastSyncPivotDistance()) .downloadPivotBlockHeader(); } FastSyncActions(
      final SynchronizerConfiguration syncConfig,
      final ProtocolSchedule protocolSchedule,
      final ProtocolContext protocolContext,
      final EthContext ethContext,
      final SyncState syncState,
      final MetricsSystem metricsSystem); CompletableFuture<FastSyncState> waitForSuitablePeers(final FastSyncState fastSyncState); CompletableFuture<T> scheduleFutureTask(
      final Supplier<CompletableFuture<T>> future, final Duration duration); CompletableFuture<FastSyncState> selectPivotBlock(final FastSyncState fastSyncState); CompletableFuture<FastSyncState> downloadPivotBlockHeader(
      final FastSyncState currentState); ChainDownloader createChainDownloader(final FastSyncState currentState);  }### Answer:
@Test public void downloadPivotBlockHeaderShouldUseExistingPivotBlockHeaderIfPresent() { final BlockHeader pivotHeader = new BlockHeaderTestFixture().number(1024).buildHeader(); final FastSyncState expected = new FastSyncState(pivotHeader); assertThat(fastSyncActions.downloadPivotBlockHeader(expected)).isCompletedWithValue(expected); }
@Test public void downloadPivotBlockHeaderShouldRetrievePivotBlockHeader() { syncConfig = SynchronizerConfiguration.builder().fastSyncMinimumPeerCount(1).build(); fastSyncActions = createFastSyncActions(syncConfig); final RespondingEthPeer peer = EthProtocolManagerTestUtil.createPeer(ethProtocolManager, 1001); final CompletableFuture<FastSyncState> result = fastSyncActions.downloadPivotBlockHeader(new FastSyncState(1)); assertThat(result).isNotCompleted(); final RespondingEthPeer.Responder responder = RespondingEthPeer.blockchainResponder(blockchain); peer.respond(responder); assertThat(result).isCompletedWithValue(new FastSyncState(blockchain.getBlockHeader(1).get())); }