@Test public void secureLoanTestDefaultMintableSimple() throws Exception{ TestSpace ts = prepareTestSpace(); ts.nodes.forEach(n->n.config.setIsFreeRegistrationsAllowedFromYaml(true)); PrivateKey lenderKey = TestKeys.privateKey(1); PrivateKey borrowerKey = TestKeys.privateKey(2); KeyAddress lenderAddress = lenderKey.getPublicKey().getLongAddress(); KeyAddress borrowerAddress = borrowerKey.getPublicKey().getLongAddress(); Contract token = ContractsService.createMintableTokenContract(new HashSet<>(Do.listOf(TestKeys.privateKey(15))), new HashSet<>(Do.listOf(lenderKey.getPublicKey())), new BigDecimal("800"), new BigDecimal("0.1"), "uEUR", "UniEuro", "Coin description"); token.seal(); assertEquals(ts.client.register(token.getPackedTransaction(),8000).state,ItemState.APPROVED); Contract collateral = new Contract(borrowerKey); collateral.getStateData().put("description","This is very valuable contract"); collateral.seal(); assertEquals(ts.client.register(collateral.getPackedTransaction(),8000).state,ItemState.APPROVED); Contract[] res = SecureLoanHelper.initSecureLoan(new Binder(),lenderAddress, borrowerAddress, token, Duration.ofSeconds(3), collateral, "1000",true,null,token.getIssuer().getSimpleAddress(), (String) token.getDefinition().getData().get("currency")); Contract secureLoan = res[0]; Compound compound = new Compound(); compound.addContract("loan",secureLoan,null); compound.getCompoundContract().addSignatureToSeal(borrowerKey); compound.getCompoundContract().addSignatureToSeal(lenderKey); ItemResult ir = ts.client.register(compound.getCompoundContract().getPackedTransaction(), 8000); System.out.println(ir); assertEquals(ir.state,ItemState.APPROVED); Thread.sleep(6000); res = SecureLoanHelper.defaultSecureLoan(secureLoan); secureLoan = res[0]; compound = new Compound(); compound.addContract("loan",secureLoan,null); compound.getCompoundContract().addSignatureToSeal(lenderKey); collateral = res[1]; ir = ts.client.register(compound.getCompoundContract().getPackedTransaction(), 8000); System.out.println(ir); assertEquals(ir.state,ItemState.APPROVED); collateral = collateral.createRevision(lenderKey); collateral.setOwnerKeys(TestKeys.publicKey(5)); collateral.seal(); ir = ts.client.register(collateral.getPackedTransaction(), 8000); System.out.println(ir); assertEquals(ir.state,ItemState.APPROVED); ts.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; }