@Test public void testTwoSignedContractApi() throws Exception { List<Main> mm = new ArrayList<>(); for (int i = 0; i < 4; i++) mm.add(createMain("node" + (i + 1), false)); Main main = mm.get(0); main.config.setIsFreeRegistrationsAllowedFromYaml(true); Client client = new Client(TestKeys.privateKey(20), main.myInfo, null); Set<PrivateKey> martyPrivateKeys = new HashSet<>(asList(TestKeys.privateKey(1))); Set<PrivateKey> stepaPrivateKeys = new HashSet<>(asList(TestKeys.privateKey(2))); Set<PublicKey> stepaPublicKeys = new HashSet<>(asList(TestKeys.publicKey(2))); Contract baseContract = Contract.fromDslFile(ROOT_PATH + "DeLoreanOwnership.yml"); PrivateKey manufacturePrivateKey = new PrivateKey(Do.read(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey")); baseContract.addSignerKey(manufacturePrivateKey); baseContract.seal(); baseContract.check(); baseContract.traceErrors(); Contract twoSignContract = ContractsService.createTwoSignedContract(baseContract, martyPrivateKeys, stepaPublicKeys, false); twoSignContract = Contract.fromPackedTransaction(twoSignContract.getPackedTransaction()); twoSignContract.addSignatureToSeal(stepaPrivateKeys); twoSignContract.check(); twoSignContract.traceErrors(); ItemResult itemResult = client.register(twoSignContract.getPackedTransaction(), 5000); System.out.println("twoSignContract : " + itemResult); assertEquals(ItemState.DECLINED, itemResult.state); twoSignContract = Contract.fromPackedTransaction(twoSignContract.getPackedTransaction()); twoSignContract.addSignatureToSeal(martyPrivateKeys); twoSignContract.check(); twoSignContract.traceErrors(); System.out.println("Contract with two signature is valid: " + twoSignContract.isOk()); itemResult = client.register(twoSignContract.getPackedTransaction(), 5000); System.out.println("twoSignContract : " + itemResult); assertEquals(ItemState.APPROVED, 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; }