@Test public void tttt() throws Exception { boolean refAsNew = true; PrivateKey key = TestKeys.privateKey(1); TestSpace testSpace = prepareTestSpace(key); testSpace.nodes.forEach(m -> { m.config.setIsFreeRegistrationsAllowedFromYaml(true); }); Contract contractMark = new Contract(key); contractMark.seal(); HashId origin = contractMark.getId(); Contract contractMark2 = new Contract(key); contractMark2.seal(); HashId origin2 = contractMark2.getId(); Contract contract = new Contract(key); SimpleRole issuer = new SimpleRole("issuer"); issuer.addKeyRecord(new KeyRecord(key.getPublicKey())); Reference ref = new Reference(contract); ref.type = Reference.TYPE_EXISTING_STATE; ref.setName(origin.toString()); List<Object> conditionsList = new ArrayList<>(); conditionsList.add(REFERENCE_CONDITION_PREFIX + "\"" + origin.toBase64String() + "\""); conditionsList.add(REFERENCE_CONDITION2); Binder conditions = Binder.of(Reference.conditionsModeType.all_of.name(), conditionsList); ref.setConditions(conditions); Reference ref2 = new Reference(contract); ref2.type = Reference.TYPE_EXISTING_STATE; ref2.setName(origin2.toString()); List<Object> conditionsList2 = new ArrayList<>(); conditionsList2.add(REFERENCE_CONDITION_PREFIX + "\"" + origin2.toBase64String() + "\""); conditionsList2.add(REFERENCE_CONDITION2); Binder conditions2 = Binder.of(Reference.conditionsModeType.all_of.name(), conditionsList2); ref2.setConditions(conditions2); contract.addReference(ref); issuer.addRequiredReference(ref, Role.RequiredMode.ALL_OF); contract.addReference(ref2); issuer.addRequiredReference(ref2, Role.RequiredMode.ALL_OF); contract.registerRole(issuer); contract.setOwnerKeys(key); contract.seal(); ItemResult ir = testSpace.client.register(contract.getPackedTransaction(), 5000); assertEquals(ir.state, ItemState.DECLINED); contract.seal(); contract.getTransactionPack().addReferencedItem(contractMark); contract.getTransactionPack().addReferencedItem(contractMark2); ir = testSpace.client.register(contract.getPackedTransaction(), 5000); assertEquals(ir.state, ItemState.DECLINED); if (refAsNew) { contract.addNewItems(contractMark); contract.addNewItems(contractMark2); } else { testSpace.client.register(contractMark.getPackedTransaction(), 5000); testSpace.client.register(contractMark2.getPackedTransaction(), 5000); } contract.seal(); if (!refAsNew) { contract.getTransactionPack().addReferencedItem(contractMark); contract.getTransactionPack().addReferencedItem(contractMark2); } ir = testSpace.client.register(contract.getPackedTransaction(), 5000); assertEquals(ir.state, ItemState.APPROVED); contract = contract.createRevision(key); contract.addSignerKey(key); contract.setOwnerKeys(TestKeys.privateKey(2).getPublicKey()); contract.seal(); ir = testSpace.client.register(contract.getPackedTransaction(), 5000); assertEquals(ir.state, ItemState.APPROVED); testSpace.nodes.forEach(n -> n.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; }