@Test public void networkReconfigurationTestSerial() throws Exception { List<Main> mm = new ArrayList<>(); for (int i = 0; i < 4; i++) { mm.add(createMain("node" + (i + 1), "_dynamic_test", false)); } for (Main m : mm) { m.shutdown(); } mm.clear(); List<String> dbUrls = new ArrayList<>(); Thread.sleep(1000); dbUrls.add("jdbc:postgresql: dbUrls.add("jdbc:postgresql: dbUrls.add("jdbc:postgresql: dbUrls.add("jdbc:postgresql: for (int i = 0; i < 4; i++) { mm.add(createMainFromDb(dbUrls.get(i), false)); } PrivateKey myKey = TestKeys.privateKey(3); Main main = mm.get(3); PrivateKey universaKey = new PrivateKey(Do.read("./src/test_contracts/keys/u_key.private.unikey")); Contract contract = new Contract(universaKey); contract.seal(); assertTrue(contract.isOk()); int attempts = 3; Client client = new Client(universaKey, main.myInfo, null); ItemResult rr = client.register(contract.getPackedTransaction(), 5000); while (attempts-- > 0) { rr = client.getState(contract.getId()); System.out.println(rr); Thread.currentThread().sleep(1000); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.PENDING_POSITIVE); contract = new Contract(universaKey); contract.seal(); assertTrue(contract.isOk()); Client clientKnown = new Client(universaKey, mm.get(0).myInfo, null); clientKnown.register(contract.getPackedTransaction(), 15000); while (true) { rr = clientKnown.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.APPROVED); for (int i = 0; i < 3; i++) { mm.get(i).node.addNode(main.myInfo); } contract = new Contract(universaKey); contract.seal(); assertTrue(contract.isOk()); client.register(contract.getPackedTransaction(), 15000); while (true) { rr = client.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.APPROVED); for (int i = 0; i < 3; i++) { mm.get(i).node.removeNode(main.myInfo); } contract = new Contract(universaKey); contract.seal(); assertTrue(contract.isOk()); attempts = 3; rr = client.register(contract.getPackedTransaction(), 15000); while (attempts-- > 0) { rr = client.getState(contract.getId()); Thread.currentThread().sleep(1000); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.PENDING_POSITIVE); contract = new Contract(universaKey); contract.seal(); assertTrue(contract.isOk()); clientKnown.register(contract.getPackedTransaction(), 15000); while (true) { rr = clientKnown.getState(contract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.APPROVED); for (Main m : mm) { m.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; }