@Override
  protected CompletableFuture<Void> sendOutgoingPacket(
      final DiscoveryPeer toPeer, final Packet packet) {
    final CompletableFuture<Void> result = new CompletableFuture<>();
    if (!this.isRunning) {
      result.completeExceptionally(new Exception("Attempt to send message from an inactive agent"));
    }

    final MockPeerDiscoveryAgent toAgent = agentNetwork.get(toPeer.getId());
    if (toAgent == null) {
      result.completeExceptionally(
          new Exception(
              "Attempt to send to unknown peer.  Agents must be constructed through PeerDiscoveryTestHelper."));
      return result;
    }

    final DiscoveryPeer agentPeer = toAgent.getAdvertisedPeer().get();
    if (!toPeer.getEndpoint().getHost().equals(agentPeer.getEndpoint().getHost())) {
      LOG.warn(
          "Attempt to send packet to discovery peer using the wrong host address.  Sending to {}, but discovery peer is listening on {}",
          toPeer.getEndpoint().getHost(),
          agentPeer.getEndpoint().getHost());
    } else if (toPeer.getEndpoint().getUdpPort() != agentPeer.getEndpoint().getUdpPort()) {
      LOG.warn(
          "Attempt to send packet to discovery peer using the wrong udp port.  Sending to {}, but discovery peer is listening on {}",
          toPeer.getEndpoint().getUdpPort(),
          agentPeer.getEndpoint().getUdpPort());
    } else if (!toAgent.isRunning) {
      LOG.warn("Attempt to send packet to an inactive peer.");
    } else {
      toAgent.processIncomingPacket(this, packet);
    }
    result.complete(null);
    return result;
  }
Get and clear the list of any incoming packets to this agent.

@return A list of packets received by this agent
ethereum/p2p/src/test/java/org/hyperledger/besu/ethereum/p2p/discovery/internal/MockPeerDiscoveryAgent.java