@Test public void shouldStartConnectionManagerAfterP2pAndDiscoveryStarted() { final SafeFuture<Void> p2pStart = new SafeFuture<>(); final SafeFuture<Void> discoveryStart = new SafeFuture<>(); final SafeFuture<Object> connectionManagerStart = new SafeFuture<>(); doReturn(p2pStart).when(p2pNetwork).start(); doReturn(discoveryStart).when(discoveryService).start(); doReturn(connectionManagerStart).when(connectionManager).start(); final SafeFuture<?> started = discoveryNetwork.start(); verify(p2pNetwork).start(); verify(discoveryService).start(); verify(connectionManager, never()).start(); p2pStart.complete(null); verify(connectionManager, never()).start(); discoveryStart.complete(null); verify(connectionManager).start(); assertThat(started).isNotDone(); connectionManagerStart.complete(null); assertThat(started).isCompleted(); }
@Override public SafeFuture<?> start() { return SafeFuture.allOfFailFast(p2pNetwork.start(), discoveryService.start()) .thenCompose(__ -> connectionManager.start()) .thenRun(() -> getEnr().ifPresent(StatusLogger.STATUS_LOG::listeningForDiscv5)); }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { @Override public SafeFuture<?> start() { return SafeFuture.allOfFailFast(p2pNetwork.start(), discoveryService.start()) .thenCompose(__ -> connectionManager.start()) .thenRun(() -> getEnr().ifPresent(StatusLogger.STATUS_LOG::listeningForDiscv5)); } }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { @Override public SafeFuture<?> start() { return SafeFuture.allOfFailFast(p2pNetwork.start(), discoveryService.start()) .thenCompose(__ -> connectionManager.start()) .thenRun(() -> getEnr().ifPresent(StatusLogger.STATUS_LOG::listeningForDiscv5)); } DiscoveryNetwork(
      final P2PNetwork<P> p2pNetwork,
      final DiscoveryService discoveryService,
      final ConnectionManager connectionManager); }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { @Override public SafeFuture<?> start() { return SafeFuture.allOfFailFast(p2pNetwork.start(), discoveryService.start()) .thenCompose(__ -> connectionManager.start()) .thenRun(() -> getEnr().ifPresent(StatusLogger.STATUS_LOG::listeningForDiscv5)); } DiscoveryNetwork(
      final P2PNetwork<P> p2pNetwork,
      final DiscoveryService discoveryService,
      final ConnectionManager connectionManager); void initialize(); static DiscoveryNetwork<P> create(
      final MetricsSystem metricsSystem,
      final AsyncRunner asyncRunner,
      final KeyValueStore<String, Bytes> kvStore,
      final P2PNetwork<P> p2pNetwork,
      final PeerSelectionStrategy peerSelectionStrategy,
      final NetworkConfig p2pConfig); @Override SafeFuture<?> start(); @Override SafeFuture<?> stop(); void addStaticPeer(final String peerAddress); @Override Optional<String> getEnr(); @Override Optional<String> getDiscoveryAddress(); void setLongTermAttestationSubnetSubscriptions(Iterable<Integer> subnetIds); void setPreGenesisForkInfo(); void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo); @Override long subscribeConnect(final PeerConnectedSubscriber<P> subscriber); @Override void unsubscribeConnect(final long subscriptionId); @Override Optional<P> getPeer(final NodeId id); @Override Stream<P> streamPeers(); }
DiscoveryNetwork extends DelegatingP2PNetwork<P> { @Override public SafeFuture<?> start() { return SafeFuture.allOfFailFast(p2pNetwork.start(), discoveryService.start()) .thenCompose(__ -> connectionManager.start()) .thenRun(() -> getEnr().ifPresent(StatusLogger.STATUS_LOG::listeningForDiscv5)); } DiscoveryNetwork(
      final P2PNetwork<P> p2pNetwork,
      final DiscoveryService discoveryService,
      final ConnectionManager connectionManager); void initialize(); static DiscoveryNetwork<P> create(
      final MetricsSystem metricsSystem,
      final AsyncRunner asyncRunner,
      final KeyValueStore<String, Bytes> kvStore,
      final P2PNetwork<P> p2pNetwork,
      final PeerSelectionStrategy peerSelectionStrategy,
      final NetworkConfig p2pConfig); @Override SafeFuture<?> start(); @Override SafeFuture<?> stop(); void addStaticPeer(final String peerAddress); @Override Optional<String> getEnr(); @Override Optional<String> getDiscoveryAddress(); void setLongTermAttestationSubnetSubscriptions(Iterable<Integer> subnetIds); void setPreGenesisForkInfo(); void setForkInfo(final ForkInfo currentForkInfo, final Optional<Fork> nextForkInfo); @Override long subscribeConnect(final PeerConnectedSubscriber<P> subscriber); @Override void unsubscribeConnect(final long subscriptionId); @Override Optional<P> getPeer(final NodeId id); @Override Stream<P> streamPeers(); static final String ATTESTATION_SUBNET_ENR_FIELD; static final String ETH2_ENR_FIELD; }