@Test public void pingTest() throws Exception { TestSpace ts = prepareTestSpace(); ts.nodes.forEach(n-> { try { n.config.getAddressesWhiteList().add(TestKeys.publicKey(1).getLongAddress()); } catch (EncryptionError encryptionError) { encryptionError.printStackTrace(); } }); Client client1 = new Client("./src/test_node_config_v2/test_node_config_v2.json",System.getProperty("java.io.tmpdir"),TestKeys.privateKey(10)); try { Binder resErr = client1.getClient(0).pingNode(3,10000); fail(); } catch (Exception e) { System.out.println(e.getMessage()); } Client client = new Client("./src/test_node_config_v2/test_node_config_v2.json",System.getProperty("java.io.tmpdir"),TestKeys.privateKey(1)); try { Binder resErr = client.getClient(0).pingNode(33,10000); fail(); } catch (Exception e) { System.out.println(e.getMessage()); } for(int i = 0; i < client.size();i++) { for(int j = 0; j < client.size();j++) { if(j == i) continue; Binder res = client.getClient(i).pingNode(j + 1, 10000); System.out.println(i+"->"+j+" " +res); assertTrue(res.getIntOrThrow("UDP") >= 0); assertTrue(res.getIntOrThrow("UDP") < 10); assertTrue(res.getIntOrThrow("TCP") >= 0); assertTrue(res.getIntOrThrow("TCP") < 15); } } ts.nodes.remove(ts.nodes.size()-1).shutdown(); for(int i = 0; i < client.size()-1;i++) { for(int j = 0; j < client.size();j++) { if(j == i) continue; Binder res = client.getClient(i).pingNode(j + 1, 500); if(j < client.size()-1) { assertTrue(res.getIntOrThrow("UDP") >= 0); assertTrue(res.getIntOrThrow("UDP") < 10); assertTrue(res.getIntOrThrow("TCP") >= 0); assertTrue(res.getIntOrThrow("TCP") < 10); } else { assertEquals(res.getIntOrThrow("UDP"),-1); assertEquals(res.getIntOrThrow("TCP"),-1); } } } ts.shutdown(); }
public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); }
Main { public void shutdown() { try { if (hookThread != null) Runtime.getRuntime().removeShutdownHook(hookThread); ledger.close(); log("shutting down"); network.shutdown(); clientHTTPServer.shutdown(); } catch (Exception e) { } synchronized (parser) { parser.notifyAll(); } try { logger.close(); } catch (Exception e) { e.printStackTrace(); } } Main(String[] args); static void main(String[] args); void waitReady(); void shutdown(); void setVerboseLevel(int level); void setUDPVerboseLevel(int level); void restartUDPAdapter(); PublicKey getNodePublicKey(); static final String NODE_VERSION; final Reporter reporter; final BufferedLogger logger; public NetConfig netConfig; public NetworkV2 network; final Config config; public NodeInfo myInfo; public Node node; public ItemCache cache; public ParcelCache parcelCache; public PaidOperationCache paidOperationCache; }