@Ignore @Test public void reconfigurationContractTest() throws Exception { PrivateKey issuerKey = new PrivateKey(Do.read("./src/test_contracts/keys/reconfig_key.private.unikey")); List<Main> mm = new ArrayList<>(); List<PrivateKey> nodeKeys = new ArrayList<>(); List<PrivateKey> nodeKeysNew = new ArrayList<>(); for (int i = 0; i < 4; i++) { mm.add(createMain("node" + (i + 1), "_dynamic_test", false)); if (i < 3) nodeKeys.add(new PrivateKey(Do.read("./src/test_node_config_v2_dynamic_test/node" + (i + 1) + "/tmp/node2_" + (i + 1) + ".private.unikey"))); nodeKeysNew.add(new PrivateKey(Do.read("./src/test_node_config_v2_dynamic_test/node" + (i + 1) + "/tmp/node2_" + (i + 1) + ".private.unikey"))); } List<NodeInfo> netConfig = mm.get(0).netConfig.toList(); List<NodeInfo> netConfigNew = mm.get(3).netConfig.toList(); for (Main m : mm) { m.shutdown(); } mm.clear(); Contract configContract = createNetConfigContract(netConfig, issuerKey); List<String> dbUrls = new ArrayList<>(); 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)); } Client client = new Client(TestKeys.privateKey(0), mm.get(0).myInfo, null); Parcel parcel = createParcelWithFreshU(client, configContract, Do.listOf(issuerKey)); client.registerParcelWithState(parcel.pack(), 15000); ItemResult rr; while (true) { rr = client.getState(configContract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.APPROVED); configContract = createNetConfigContract(configContract, netConfigNew, nodeKeys); parcel = createParcelWithFreshU(client, configContract, nodeKeys); client.registerParcelWithState(parcel.pack(), 15000); while (true) { rr = client.getState(configContract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.APPROVED); Thread.sleep(1000); for (Main m : mm) { assertEquals(m.config.getPositiveConsensus(), 3); } configContract = createNetConfigContract(configContract, netConfig, nodeKeys); parcel = createParcelWithFreshU(client, configContract, nodeKeys); client.registerParcelWithState(parcel.pack(), 15000); while (true) { rr = client.getState(configContract.getId()); Thread.currentThread().sleep(500); if (!rr.state.isPending()) break; } assertEquals(rr.state, ItemState.APPROVED); Thread.sleep(1000); for (Main m : mm) { assertEquals(m.config.getPositiveConsensus(), 2); } 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; }