@Test public void httpProxy() throws Exception { List<Main> nodes = new ArrayList<>(); for (int i = 0; i < 4; i++) nodes.add(createMain("node" + (i + 1), false)); nodes.forEach(n->n.config.setIsFreeRegistrationsAllowedFromYaml(true)); PrivateKey myKey = TestKeys.privateKey(3); ArrayList<Client> clientProxyToNode = new ArrayList<>(); for (int i = 0; i < 4; ++i) { Client clientProxyTo_i = new Client("./src/test_node_config_v2/test_node_config_v2.json",System.getProperty("java.io.tmpdir"),myKey); clientProxyTo_i.startProxyToNode(i, null); clientProxyToNode.add(clientProxyTo_i); } HashId testHashId = HashId.createRandom(); nodes.get(0).node.getLedger().findOrCreate(testHashId).setState(ItemState.APPROVED).save(); nodes.get(1).node.getLedger().findOrCreate(testHashId).setState(ItemState.DECLINED).save(); nodes.get(2).node.getLedger().findOrCreate(testHashId).setState(ItemState.REVOKED).save(); nodes.get(3).node.getLedger().findOrCreate(testHashId).setState(ItemState.DISCARDED).save(); System.out.println("\n\n-------------------"); ItemResult answer = clientProxyToNode.get(0).getState(testHashId); System.out.println(answer); assertEquals(ItemState.APPROVED, answer.state); answer = clientProxyToNode.get(1).getState(testHashId); System.out.println(answer); assertEquals(ItemState.DECLINED, answer.state); answer = clientProxyToNode.get(2).getState(testHashId); System.out.println(answer); assertEquals(ItemState.REVOKED, answer.state); answer = clientProxyToNode.get(3).getState(testHashId); System.out.println(answer); assertEquals(ItemState.DISCARDED, answer.state); System.out.println("-------------------\n\n"); nodes.forEach(n->n.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; }