@Test
  public void failsWhenAllPeersFail() {
    // Setup first unresponsive peer
    final RespondingEthPeer firstPeer =
        EthProtocolManagerTestUtil.createPeer(ethProtocolManager, 10);

    // Setup second unresponsive peer
    final RespondingEthPeer secondPeer =
        EthProtocolManagerTestUtil.createPeer(ethProtocolManager, 9);

    // Execute task and wait for response
    final T requestedData = generateDataToBeRequested();
    final EthTask<T> task = createTask(requestedData);
    final CompletableFuture<T> future = task.run();

    for (int i = 0; i < maxRetries && !future.isDone(); i++) {
      // First peer is unresponsive
      firstPeer.respondWhile(RespondingEthPeer.emptyResponder(), firstPeer::hasOutstandingRequests);
      // Second peer is unresponsive
      secondPeer.respondWhile(
          RespondingEthPeer.emptyResponder(), secondPeer::hasOutstandingRequests);
    }

    assertThat(future.isDone()).isTrue();
    assertThat(future.isCompletedExceptionally()).isTrue();
    assertThatThrownBy(future::get).hasCauseInstanceOf(MaxRetriesReachedException.class);

    // since we are below the max number of peers, no peer should be disconnected
    assertThat(firstPeer.getEthPeer().isDisconnected()).isFalse();
    assertThat(secondPeer.getEthPeer().isDisconnected()).isFalse();
  }
Tests ethTasks that request data from the network, and retry until all of the data is received.

@param <T> The type of data being requested from the network
ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/RetryingSwitchingPeerMessageTaskTest.java