@Test
  public void recordsTimeoutAgainstPeerWhenTaskTimesOut() {
    peersDoTimeout.set(true);
    // Setup a unresponsive peer
    final RespondingEthPeer respondingEthPeer =
        EthProtocolManagerTestUtil.createPeer(ethProtocolManager, 32);

    // Setup data to be requested
    final T requestedData = generateDataToBeRequested();

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

    assertThat(future.isCompletedExceptionally()).isTrue();
    assertThat(
            respondingEthPeer.getEthPeer().timeoutCounts().values().stream()
                .mapToInt(AtomicInteger::get)
                .sum())
        .isEqualTo(1);
  }
Tests ethTasks that interact with a single peer to retrieve data from the network.

@param <T> The type of data being retrieved.
ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/ethtaskutils/PeerMessageTaskTest.java