@Test public void startNode() throws Exception { String path = new File("src/test_node_config_v2/node1").getAbsolutePath(); System.out.println(path); String[] args = new String[]{"--test", "--config", path, "--nolog"}; Main main = new Main(args); main.waitReady(); BufferedLogger l = main.logger; Client client = new Client( "http: TestKeys.privateKey(3), main.getNodePublicKey(), null ); Binder data = client.command("status"); data.getStringOrThrow("status"); BasicHttpClient.Answer a = client.request("ping"); assertEquals("200: {ping=pong}", a.toString()); Contract c = new Contract(); c.setIssuerKeys(TestKeys.publicKey(3)); c.addSignerKey(TestKeys.privateKey(3)); c.registerRole(new RoleLink("owner", "issuer")); c.registerRole(new RoleLink("creator", "issuer")); c.setExpiresAt(ZonedDateTime.now().plusDays(2)); byte[] sealed = c.seal(); Contract c1 = new Contract(sealed); assertArrayEquals(c.getLastSealedBinary(), c1.getLastSealedBinary()); main.cache.put(c, null); assertNotNull(main.cache.get(c.getId())); URL url = new URL("http: HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); assertEquals(200, con.getResponseCode()); byte[] data2 = Do.read(con.getInputStream()); assertArrayEquals(c.getPackedTransaction(), data2); url = new URL("http: con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); assertEquals(200, con.getResponseCode()); Binder bres = Boss.unpack((Do.read(con.getInputStream()))) .getBinderOrThrow("response"); List<Binder> ni = bres.getBinders("nodes"); String pubUrls = ni.stream().map(x -> x.getStringOrThrow("url")) .collect(Collectors.toList()) .toString(); assertEquals("[http: main.shutdown(); main.logger.stopInterceptingStdOut(); main.logger.getCopy().forEach(x -> System.out.println(x)); }
private void startNode() throws SQLException, IOException { config.setConsensusConfigUpdater((config, n) -> { int negative; int positive; if(n < 3) { negative = 1; positive = n; } else if(n < 10) { negative = 2; positive = n-1; } else { positive = (int) Math.ceil(n * 0.9); negative = n + 1 - positive; } int resyncBreak = (int) Math.ceil(n * 0.2); if (resyncBreak < 1) resyncBreak = 1; if( resyncBreak+positive == n) resyncBreak += 1; log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak); config.setPositiveConsensus(positive); config.setNegativeConsensus(negative); config.setResyncBreakConsensus(resyncBreak); }); network = new NetworkV2(netConfig, myInfo, nodeKey); node = new Node(config, myInfo, ledger, network, nodeKey,new File(configRoot+"/config/contracts")); cache = node.getCache(); parcelCache = node.getParcelCache(); paidOperationCache = node.getPaidOperationCache(); envCache = node.getEnvCache(); StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A==")); if( r != null ) r.destroy(); clientHTTPServer.setConfig(config); clientHTTPServer.setNode(node); clientHTTPServer.setCache(cache); clientHTTPServer.setParcelCache(parcelCache); clientHTTPServer.setPaidOperationCache(paidOperationCache); clientHTTPServer.setEnvCache(envCache); clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost")); }
Main { private void startNode() throws SQLException, IOException { config.setConsensusConfigUpdater((config, n) -> { int negative; int positive; if(n < 3) { negative = 1; positive = n; } else if(n < 10) { negative = 2; positive = n-1; } else { positive = (int) Math.ceil(n * 0.9); negative = n + 1 - positive; } int resyncBreak = (int) Math.ceil(n * 0.2); if (resyncBreak < 1) resyncBreak = 1; if( resyncBreak+positive == n) resyncBreak += 1; log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak); config.setPositiveConsensus(positive); config.setNegativeConsensus(negative); config.setResyncBreakConsensus(resyncBreak); }); network = new NetworkV2(netConfig, myInfo, nodeKey); node = new Node(config, myInfo, ledger, network, nodeKey,new File(configRoot+"/config/contracts")); cache = node.getCache(); parcelCache = node.getParcelCache(); paidOperationCache = node.getPaidOperationCache(); envCache = node.getEnvCache(); StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A==")); if( r != null ) r.destroy(); clientHTTPServer.setConfig(config); clientHTTPServer.setNode(node); clientHTTPServer.setCache(cache); clientHTTPServer.setParcelCache(parcelCache); clientHTTPServer.setPaidOperationCache(paidOperationCache); clientHTTPServer.setEnvCache(envCache); clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost")); } }
Main { private void startNode() throws SQLException, IOException { config.setConsensusConfigUpdater((config, n) -> { int negative; int positive; if(n < 3) { negative = 1; positive = n; } else if(n < 10) { negative = 2; positive = n-1; } else { positive = (int) Math.ceil(n * 0.9); negative = n + 1 - positive; } int resyncBreak = (int) Math.ceil(n * 0.2); if (resyncBreak < 1) resyncBreak = 1; if( resyncBreak+positive == n) resyncBreak += 1; log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak); config.setPositiveConsensus(positive); config.setNegativeConsensus(negative); config.setResyncBreakConsensus(resyncBreak); }); network = new NetworkV2(netConfig, myInfo, nodeKey); node = new Node(config, myInfo, ledger, network, nodeKey,new File(configRoot+"/config/contracts")); cache = node.getCache(); parcelCache = node.getParcelCache(); paidOperationCache = node.getPaidOperationCache(); envCache = node.getEnvCache(); StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A==")); if( r != null ) r.destroy(); clientHTTPServer.setConfig(config); clientHTTPServer.setNode(node); clientHTTPServer.setCache(cache); clientHTTPServer.setParcelCache(parcelCache); clientHTTPServer.setPaidOperationCache(paidOperationCache); clientHTTPServer.setEnvCache(envCache); clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost")); } Main(String[] args); }
Main { private void startNode() throws SQLException, IOException { config.setConsensusConfigUpdater((config, n) -> { int negative; int positive; if(n < 3) { negative = 1; positive = n; } else if(n < 10) { negative = 2; positive = n-1; } else { positive = (int) Math.ceil(n * 0.9); negative = n + 1 - positive; } int resyncBreak = (int) Math.ceil(n * 0.2); if (resyncBreak < 1) resyncBreak = 1; if( resyncBreak+positive == n) resyncBreak += 1; log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak); config.setPositiveConsensus(positive); config.setNegativeConsensus(negative); config.setResyncBreakConsensus(resyncBreak); }); network = new NetworkV2(netConfig, myInfo, nodeKey); node = new Node(config, myInfo, ledger, network, nodeKey,new File(configRoot+"/config/contracts")); cache = node.getCache(); parcelCache = node.getParcelCache(); paidOperationCache = node.getPaidOperationCache(); envCache = node.getEnvCache(); StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A==")); if( r != null ) r.destroy(); clientHTTPServer.setConfig(config); clientHTTPServer.setNode(node); clientHTTPServer.setCache(cache); clientHTTPServer.setParcelCache(parcelCache); clientHTTPServer.setPaidOperationCache(paidOperationCache); clientHTTPServer.setEnvCache(envCache); clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost")); } 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 { private void startNode() throws SQLException, IOException { config.setConsensusConfigUpdater((config, n) -> { int negative; int positive; if(n < 3) { negative = 1; positive = n; } else if(n < 10) { negative = 2; positive = n-1; } else { positive = (int) Math.ceil(n * 0.9); negative = n + 1 - positive; } int resyncBreak = (int) Math.ceil(n * 0.2); if (resyncBreak < 1) resyncBreak = 1; if( resyncBreak+positive == n) resyncBreak += 1; log(myInfo.getNumber() + ": Network consensus is set to (negative/positive/resyncBreak): " + negative + " / " + positive + " / " + resyncBreak); config.setPositiveConsensus(positive); config.setNegativeConsensus(negative); config.setResyncBreakConsensus(resyncBreak); }); network = new NetworkV2(netConfig, myInfo, nodeKey); node = new Node(config, myInfo, ledger, network, nodeKey,new File(configRoot+"/config/contracts")); cache = node.getCache(); parcelCache = node.getParcelCache(); paidOperationCache = node.getPaidOperationCache(); envCache = node.getEnvCache(); StateRecord r = ledger.getRecord(HashId.withDigest("bS/c4YMidaVuzTBhHLkGPFAvPbZQHybzQnXAoBwaZYM8eLYb7mAkVYEpuqKRXYc7anqX47BeNdvFN1n7KluH9A==")); if( r != null ) r.destroy(); clientHTTPServer.setConfig(config); clientHTTPServer.setNode(node); clientHTTPServer.setCache(cache); clientHTTPServer.setParcelCache(parcelCache); clientHTTPServer.setPaidOperationCache(paidOperationCache); clientHTTPServer.setEnvCache(envCache); clientHTTPServer.setLocalCors(myInfo.getPublicHost().equals("localhost")); } 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; }