### Question:
LocalhostNetworkNode extends NetworkNode { @Override public void start(@Nullable SetupListener setupListener) { if (setupListener != null) addSetupListener(setupListener); createExecutorService(); UserThread.runAfter(() -> { nodeAddressProperty.set(new NodeAddress("localhost", servicePort)); setupListeners.stream().forEach(SetupListener::onTorNodeReady); UserThread.runAfter(() -> { try { startServer(new ServerSocket(servicePort)); } catch (IOException e) { e.printStackTrace(); log.error("Exception at startServer: " + e.getMessage()); } setupListeners.stream().forEach(SetupListener::onHiddenServicePublished); }, simulateTorDelayTorNode, TimeUnit.MILLISECONDS); }, simulateTorDelayHiddenService, TimeUnit.MILLISECONDS); } LocalhostNetworkNode(int port, NetworkProtoResolver networkProtoResolver); static void setSimulateTorDelayTorNode(int simulateTorDelayTorNode); static void setSimulateTorDelayHiddenService(int simulateTorDelayHiddenService); @Override void start(@Nullable SetupListener setupListener);  }### Answer:
@Test public void testMessage() throws InterruptedException, IOException { CountDownLatch msgLatch = new CountDownLatch(2); LocalhostNetworkNode node1 = new LocalhostNetworkNode(9001, TestUtils.getNetworkProtoResolver()); node1.addMessageListener((message, connection) -> { log.debug("onMessage node1 " + message); msgLatch.countDown(); }); CountDownLatch startupLatch = new CountDownLatch(2); node1.start(new SetupListener() { @Override public void onTorNodeReady() { log.debug("onTorNodeReady"); } @Override public void onHiddenServicePublished() { log.debug("onHiddenServiceReady"); startupLatch.countDown(); } @Override public void onSetupFailed(Throwable throwable) { log.debug("onSetupFailed"); } @Override public void onRequestCustomBridges() { } }); LocalhostNetworkNode node2 = new LocalhostNetworkNode(9002, TestUtils.getNetworkProtoResolver()); node2.addMessageListener((message, connection) -> { log.debug("onMessage node2 " + message); msgLatch.countDown(); }); node2.start(new SetupListener() { @Override public void onTorNodeReady() { log.debug("onTorNodeReady 2"); } @Override public void onHiddenServicePublished() { log.debug("onHiddenServiceReady 2"); startupLatch.countDown(); } @Override public void onSetupFailed(Throwable throwable) { log.debug("onSetupFailed 2"); } @Override public void onRequestCustomBridges() { } }); startupLatch.await(); msgLatch.await(); CountDownLatch shutDownLatch = new CountDownLatch(2); node1.shutDown(shutDownLatch::countDown); node2.shutDown(shutDownLatch::countDown); shutDownLatch.await(); }