### Question:
WorldDownloadState { public synchronized boolean checkCompletion( final WorldStateStorage worldStateStorage, final BlockHeader header) { if (!internalFuture.isDone() && pendingRequests.allTasksCompleted()) { if (rootNodeData == null) { enqueueRequest(NodeDataRequest.createAccountDataRequest(header.getStateRoot())); return false; } final Updater updater = worldStateStorage.updater(); updater.putAccountStateTrieNode(header.getStateRoot(), rootNodeData); updater.commit(); internalFuture.complete(null); notifyAll(); LOG.info("Finished downloading world state from peers"); return true; } else { return false; } } WorldDownloadState(
      final CachingTaskCollection<NodeDataRequest> pendingRequests,
      final int maxRequestsWithoutProgress,
      final long minMillisBeforeStalling,
      final Clock clock); boolean downloadWasResumed(); void addOutstandingTask(final EthTask<?> task); void removeOutstandingTask(final EthTask<?> task); int getOutstandingTaskCount(); CompletableFuture<Void> getDownloadFuture(); synchronized void enqueueRequest(final NodeDataRequest request); synchronized void enqueueRequests(final Stream<NodeDataRequest> requests); synchronized Task<NodeDataRequest> dequeueRequestBlocking(); synchronized void setRootNodeData(final Bytes rootNodeData); synchronized void requestComplete(final boolean madeProgress); int getRequestsSinceLastProgress(); synchronized boolean checkCompletion(
      final WorldStateStorage worldStateStorage, final BlockHeader header); synchronized boolean isDownloading(); synchronized void setWorldStateDownloadProcess(
      final WorldStateDownloadProcess worldStateDownloadProcess); synchronized void notifyTaskAvailable(); CompletableFuture<Void> startDownload(
      final WorldStateDownloadProcess worldStateDownloadProcess, final EthScheduler ethScheduler);  }### Answer:
@Test public void shouldStoreRootNodeBeforeReturnedFutureCompletes() { final CompletableFuture<Void> postFutureChecks = future.thenAccept( result -> assertThat(worldStateStorage.getAccountStateTrieNode(ROOT_NODE_HASH)) .contains(ROOT_NODE_DATA)); downloadState.checkCompletion(worldStateStorage, header); assertThat(future).isCompleted(); assertThat(postFutureChecks).isCompleted(); }