@Test public void informerTest() throws Exception { TestSpace ts = prepareTestSpace(); Contract payment = getApprovedUContract(ts); Set<PrivateKey> paymentKeys = new HashSet(); paymentKeys.add(ts.myKey); Contract c = new Contract(TestKeys.privateKey(1)); Binder s = BossBiMapper.serialize(c); ZonedDateTime cr = ZonedDateTime.now().minusMonths(1); s.getBinder("definition").set("created_at", cr); s.getBinder("state").set("created_at", cr); c = BossBiMapper.deserialize(s); c.getKeysToSignWith().add(TestKeys.privateKey(1)); c.seal(); Parcel parcel = ContractsService.createParcel(c, payment, 1, paymentKeys); ItemResult res = ts.client.registerParcelWithState(parcel.pack(), 15000); assertSame(res.state, ItemState.UNDEFINED); assertEquals(1, res.errors.size()); System.out.println(res.errors); payment = parcel.getPayment().getContract(); c = new Contract(TestKeys.privateKey(1)); for (int i = 0; i < 20; i++) { c.addNewItems(new Contract(TestKeys.privateKey(1))); } c.seal(); parcel = ContractsService.createParcel(c, payment, 1, paymentKeys); res = ts.client.registerParcelWithState(parcel.pack(), 15000); assertSame(res.state, ItemState.UNDEFINED); assertEquals(1, res.errors.size()); System.out.println(res.errors); payment = parcel.getPayment().getContract(); c = new Contract(TestKeys.privateKey(1)); Contract ri = new Contract(TestKeys.privateKey(2)); ri.seal(); c.addRevokingItems(ri); c.seal(); parcel = ContractsService.createParcel(c, payment, 1, paymentKeys); res = ts.client.registerParcelWithState(parcel.pack(), 15000); assertTrue(res.state == ItemState.DECLINED); assertEquals(1, res.errors.size()); System.out.println(res.errors); payment = parcel.getPayment().getContract(); c = new Contract(TestKeys.privateKey(1)); c.seal(); parcel = ContractsService.createParcel(c, payment, 1, paymentKeys); res = ts.client.registerParcelWithState(parcel.pack(), 15000); assertSame(res.state, ItemState.APPROVED); payment = parcel.getPayment().getContract(); c = new Contract(TestKeys.privateKey(1)); c.seal(); parcel = ContractsService.createParcel(c, payment, -1, paymentKeys); res = ts.client.registerParcelWithState(parcel.pack(), 15000); ItemResult state = ts.client.getState(parcel.getPaymentContract().getId()); assertSame(state.state, ItemState.DECLINED); assertSame(res.state, ItemState.UNDEFINED); assertEquals(0, res.errors.size()); 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; }