### Question:
RlpxAgent { public CompletableFuture<Void> stop() { if (!started.get() || !stopped.compareAndSet(false, true)) { return CompletableFuture.failedFuture( new IllegalStateException("Illegal attempt to stop " + getClass().getSimpleName())); } streamConnections().forEach((conn) -> conn.disconnect(DisconnectReason.CLIENT_QUITTING)); return connectionInitializer.stop(); } private  RlpxAgent(
      final LocalNode localNode,
      final PeerConnectionEvents connectionEvents,
      final ConnectionInitializer connectionInitializer,
      final PeerRlpxPermissions peerPermissions,
      final PeerPrivileges peerPrivileges,
      final int maxConnections,
      final int maxRemotelyInitiatedConnections,
      final MetricsSystem metricsSystem); static Builder builder(); CompletableFuture<Integer> start(); CompletableFuture<Void> stop(); Stream<? extends PeerConnection> streamConnections(); int getConnectionCount(); void connect(final Stream<? extends Peer> peerStream); void disconnect(final Bytes peerId, final DisconnectReason reason); Optional<CompletableFuture<PeerConnection>> getPeerConnection(final Peer peer); CompletableFuture<PeerConnection> connect(final Peer peer); void subscribeMessage(final Capability capability, final MessageCallback callback); void subscribeConnect(final ConnectCallback callback); void subscribeDisconnect(final DisconnectCallback callback);  }### Answer:
@Test public void stop() throws ExecutionException, InterruptedException { final CompletableFuture<Void> future = agent.stop(); assertThat(future).isDone(); assertThat(future).isCompletedExceptionally(); assertThatThrownBy(future::get) .hasCauseInstanceOf(IllegalStateException.class) .hasMessageContaining("Illegal attempt to stop"); startAgent(); final MockPeerConnection connection = (MockPeerConnection) agent.connect(createPeer()).get(); final CompletableFuture<Void> future2 = agent.stop(); assertThat(future2).isDone(); assertThat(future2).isNotCompletedExceptionally(); assertThat(connection.getDisconnectReason()).contains(DisconnectReason.CLIENT_QUITTING); final CompletableFuture<Void> future3 = agent.stop(); assertThat(future3).isDone(); assertThat(future3).isCompletedExceptionally(); assertThatThrownBy(future3::get) .hasCauseInstanceOf(IllegalStateException.class) .hasMessageContaining("Illegal attempt to stop"); }