@Test public void testMintableTokenContractApi() 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> issuerPrivateKeys = new HashSet<>(asList(TestKeys.privateKey(1))); Set<PublicKey> issuerPublicKeys = new HashSet<>(asList(TestKeys.publicKey(1))); Set<PublicKey> ownerPublicKeys = new HashSet<>(asList(TestKeys.publicKey(2))); Contract mintableTokenContract = ContractsService.createTokenContractWithEmission(issuerPrivateKeys, ownerPublicKeys, new BigDecimal("300000000000")); mintableTokenContract.check(); mintableTokenContract.traceErrors(); ItemResult itemResult = client.register(mintableTokenContract.getPackedTransaction(), 5000); System.out.println("mintableTokenContract : " + itemResult); assertEquals(ItemState.APPROVED, itemResult.state); Contract emittedContract = ContractsService.createTokenEmission(mintableTokenContract, new BigDecimal("100000000000"), issuerPrivateKeys); emittedContract.check(); emittedContract.traceErrors(); assertEquals(emittedContract.getPermissions().get("split_join").size(), 1); Binder splitJoinParams = emittedContract.getPermissions().get("split_join").iterator().next().getParams(); assertEquals(splitJoinParams.get("min_value"), "0.01"); assertEquals(splitJoinParams.get("min_unit"), "0.01"); assertEquals(splitJoinParams.get("field_name"), "amount"); assertTrue(splitJoinParams.get("join_match_fields") instanceof List); assertEquals(((List) splitJoinParams.get("join_match_fields")).get(0), "state.origin"); assertTrue(emittedContract.isPermitted("revoke", ownerPublicKeys)); assertTrue(emittedContract.isPermitted("revoke", issuerPublicKeys)); assertTrue(emittedContract.isPermitted("change_owner", ownerPublicKeys)); assertFalse(emittedContract.isPermitted("change_owner", issuerPublicKeys)); assertTrue(emittedContract.isPermitted("split_join", ownerPublicKeys)); assertFalse(emittedContract.isPermitted("split_join", issuerPublicKeys)); itemResult = client.register(emittedContract.getPackedTransaction(), 5000); System.out.println("emittedContract : " + itemResult); assertEquals(ItemState.APPROVED, itemResult.state); assertEquals(emittedContract.getStateData().getString("amount"), "400000000000"); assertEquals(ItemState.REVOKED, main.node.waitItem(mintableTokenContract.getId(), 8000).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; }