@Test public void networkStatusTest() throws Exception { TestSpace ts = prepareTestSpace(); ts.nodes.forEach(n-> { try { n.config.getAddressesWhiteList().add(TestKeys.publicKey(1).getLongAddress()); } catch (EncryptionError encryptionError) { encryptionError.printStackTrace(); } }); Client client = new Client("./src/test_node_config_v2/test_node_config_v2.json",System.getProperty("java.io.tmpdir"),TestKeys.privateKey(1)); HashId id1 = HashId.createRandom(); ts.nodes.forEach(n->n.node.getLedger().findOrCreate(id1).setState(ItemState.APPROVED).save()); assertTrue(client.isApprovedByNetwork(id1,0.9,3000)); HashId id2 = HashId.createRandom(); for(int i = 0; i < ts.nodes.size();i++) { ts.nodes.get(i).node.getLedger().findOrCreate(id2).setState(i==0?ItemState.DECLINED:ItemState.APPROVED); } for(int i = 0; i < 10;i++) { assertFalse(client.isApprovedByNetwork(id2, 0.8, 3000)); } ts.shutdown(); try { client.isApprovedByNetwork(HashId.createRandom(),0.1,3000); } catch (ClientError e) { System.out.println(e.getErrorRecord()); assertEquals(e.getErrorRecord().getError(), Errors.COMMAND_PENDING); } }
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; }