### Question:
FastSyncActions { public CompletableFuture<FastSyncState> waitForSuitablePeers(final FastSyncState fastSyncState) { if (fastSyncState.hasPivotBlockHeader()) { return waitForAnyPeer().thenApply(ignore -> fastSyncState); } LOG.debug("Waiting for at least {} peers.", syncConfig.getFastSyncMinimumPeerCount()); return waitForPeers(syncConfig.getFastSyncMinimumPeerCount()) .thenApply(successfulWaitResult -> fastSyncState); } 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 waitForPeersShouldSucceedIfEnoughPeersAreFound() { for (int i = 0; i < syncConfig.getFastSyncMinimumPeerCount(); i++) { EthProtocolManagerTestUtil.createPeer(ethProtocolManager); } final CompletableFuture<FastSyncState> result = fastSyncActions.waitForSuitablePeers(FastSyncState.EMPTY_SYNC_STATE); assertThat(result).isCompletedWithValue(FastSyncState.EMPTY_SYNC_STATE); }
@Test public void waitForPeersShouldOnlyRequireOnePeerWhenPivotBlockIsAlreadySelected() { final BlockHeader pivotHeader = new BlockHeaderTestFixture().number(1024).buildHeader(); final FastSyncState fastSyncState = new FastSyncState(pivotHeader); final CompletableFuture<FastSyncState> result = fastSyncActions.waitForSuitablePeers(fastSyncState); assertThat(result).isNotDone(); EthProtocolManagerTestUtil.createPeer(ethProtocolManager); assertThat(result).isCompletedWithValue(fastSyncState); }