@Test public void checkUnlimitRequestsBadKey() throws Exception { PrivateKey myKey = TestKeys.privateKey(3); List<Main> mm = new ArrayList<>(); for (int i = 0; i < 4; i++) mm.add(createMain("node" + (i + 1), false)); mm.forEach(x -> x.config.setIsFreeRegistrationsAllowedFromYaml(true)); Main main = mm.get(0); Client client = null; try { client = new Client(myKey, main.myInfo, null); } catch (Exception e) { System.out.println("prepareClient exception: " + e.toString()); } Set<PublicKey> ownerKeys = new HashSet(); Set<PrivateKey> keys = new HashSet(); keys.add(myKey); ownerKeys.add(myKey.getPublicKey()); Contract payment = InnerContractsService.createFreshU(100, ownerKeys); payment.check(); payment.traceErrors(); client.register(payment.getPackedTransaction()); Thread.currentThread().sleep(5000); mm.forEach(x -> x.config.setIsFreeRegistrationsAllowedFromYaml(false)); Contract unlimitContract = ContractsService.createRateLimitDisablingContract( myKey.getPublicKey(), payment, main.config.getRateLimitDisablingPayment(), keys); byte[] packedKey = unlimitContract.getTransactional().getData().getBinary("unlimited_key"); PublicKey key = new PublicKey(packedKey); assertFalse((packedKey == null) || ((key == null))); assertEquals(unlimitContract.getRevoking().get(0).getStateData().getIntOrThrow("transaction_units") - unlimitContract.getStateData().getIntOrThrow("transaction_units"), 5); unlimitContract.check(); unlimitContract.traceErrors(); assertTrue(unlimitContract.isOk()); unlimitContract.getTransactional().getData().set("unlimited_key", "badkeybadkeybadkeybadkey"); unlimitContract.seal(); client.register(unlimitContract.getPackedTransaction()); Thread.currentThread().sleep(5000); System.out.println(); ItemResult itemResult = client.getState(unlimitContract.getId()); System.out.println(">> state: " + itemResult); assertEquals(ItemState.UNDEFINED, itemResult.state); mm.forEach(x -> x.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; }