@Test public void revokeTwoContracts() throws Exception { String contractFileName1 = basePath + "contract_for_revoke1.unicon"; String contractFileName2 = basePath + "contract_for_revoke2.unicon"; System.out.println("---"); System.out.println("register contracts"); System.out.println("---"); String uContract = getApprovedUContract(); callMain2("--register", contractFileName1, contractFileName2, "--verbose", "--u", uContract, "--k", rootPath + "keys/stepan_mamontov.private.unikey"); Thread.sleep(1500); System.out.println("---"); System.out.println("check u"); System.out.println("---"); uContract = getApprovedUContract(); Contract u = CLIMain.loadContract(uContract); System.out.println("check u " + u.getId().toBase64String()); callMain2("--probe", u.getId().toBase64String(), "--verbose"); System.out.println("---"); System.out.println("revoke contracts"); System.out.println("---"); callMain2("-revoke", contractFileName1, contractFileName2, "-v", "--u", uContract, "-k", rootPath + "keys/stepan_mamontov.private.unikey", "-k", PRIVATE_KEY_PATH); Thread.sleep(1500); System.out.println("---"); System.out.println("check contracts after revoke"); System.out.println("---"); Contract c1 = CLIMain.loadContract(contractFileName1); callMain2("--probe", c1.getId().toBase64String(), "--verbose"); Contract c2 = CLIMain.loadContract(contractFileName2); callMain("--probe", c2.getId().toBase64String(), "--verbose"); Contract u2 = CLIMain.loadContract(uContract); System.out.println("check u " + u2.getId().toBase64String()); callMain2("--probe", u2.getId().toBase64String(), "--verbose"); System.out.println(output); assertEquals(0, errors.size()); assertTrue (output.indexOf(ItemState.REVOKED.name()) >= 1); }
public static Contract loadContract(String fileName, Boolean fromPackedTransaction) throws IOException { Contract contract = null; File pathFile = new File(fileName); if (pathFile.exists()) { Path path = Paths.get(fileName); byte[] data = Files.readAllBytes(path); try { if (fromPackedTransaction) { contract = Contract.fromPackedTransaction(data); } else { contract = new Contract(data); } } catch (Quantiser.QuantiserException e) { addError("QUANTIZER_COST_LIMIT", fileName, e.toString()); } } else { addError(Errors.NOT_FOUND.name(), fileName, "Path " + fileName + " does not exist"); } return contract; }
CLIMain { public static Contract loadContract(String fileName, Boolean fromPackedTransaction) throws IOException { Contract contract = null; File pathFile = new File(fileName); if (pathFile.exists()) { Path path = Paths.get(fileName); byte[] data = Files.readAllBytes(path); try { if (fromPackedTransaction) { contract = Contract.fromPackedTransaction(data); } else { contract = new Contract(data); } } catch (Quantiser.QuantiserException e) { addError("QUANTIZER_COST_LIMIT", fileName, e.toString()); } } else { addError(Errors.NOT_FOUND.name(), fileName, "Path " + fileName + " does not exist"); } return contract; } }
CLIMain { public static Contract loadContract(String fileName, Boolean fromPackedTransaction) throws IOException { Contract contract = null; File pathFile = new File(fileName); if (pathFile.exists()) { Path path = Paths.get(fileName); byte[] data = Files.readAllBytes(path); try { if (fromPackedTransaction) { contract = Contract.fromPackedTransaction(data); } else { contract = new Contract(data); } } catch (Quantiser.QuantiserException e) { addError("QUANTIZER_COST_LIMIT", fileName, e.toString()); } } else { addError(Errors.NOT_FOUND.name(), fileName, "Path " + fileName + " does not exist"); } return contract; }  }
CLIMain { public static Contract loadContract(String fileName, Boolean fromPackedTransaction) throws IOException { Contract contract = null; File pathFile = new File(fileName); if (pathFile.exists()) { Path path = Paths.get(fileName); byte[] data = Files.readAllBytes(path); try { if (fromPackedTransaction) { contract = Contract.fromPackedTransaction(data); } else { contract = new Contract(data); } } catch (Quantiser.QuantiserException e) { addError("QUANTIZER_COST_LIMIT", fileName, e.toString()); } } else { addError(Errors.NOT_FOUND.name(), fileName, "Path " + fileName + " does not exist"); } return contract; }  static void main(String[] args); static PrivateKey getPrivateKey(); static BasicHttpClientSession getSession(int nodeNumber); static void breakSession(int nodeNumber); static void clearSession(); static void clearSession(boolean full); static void saveSession(); static void setVerboseMode(boolean verboseMode); static Contract loadContract(String fileName, Boolean fromPackedTransaction); static Parcel loadParcel(String fileName); static Contract loadContract(String fileName); static void exportContract(Contract contract, String fileName, String format, Boolean jsonPretty); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners, Set<Contract> referencedItems); static boolean saveParcel(Parcel parcel, String fileName); static void saveContract(Contract contract, String fileName); static List<Wallet> findWallets(String path); static HashMap<String, Contract> findContracts(String path); static HashMap<String, Contract> findContracts(String path, Boolean recursively); static List<File> findFiles(String path, Boolean recursively); static Contract downloadContract(String url); static Parcel revokeContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment, PrivateKey... key); @Deprecated static Contract revokeContract(Contract contract, PrivateKey... key); @Deprecated static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction); static Parcel prepareForRegisterContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment); static Parcel prepareForRegisterPayingParcel(Contract contract, Contract u, int amount, int amountStorage, Set<PrivateKey> uKeys, boolean withTestPayment); static ItemResult registerParcel(Parcel parcel, int waitTime); static void registerContract(Contract contract); static void registerContract(Contract contract, int waitTime); static void setTestMode(); static void setTestRootPath(String rootPath); static void setNodeNumber(int number); static void setNodeUrl(String url); static void setTopologyFileName(String filename); static void setPrivateKey(PrivateKey key); static Reporter getReporter(); static synchronized ClientNetwork getClientNetwork(); static synchronized Map<String, PrivateKey> keysMap(); static synchronized Map<String, PrivateKey> keysMapContract(); }
CLIMain { public static Contract loadContract(String fileName, Boolean fromPackedTransaction) throws IOException { Contract contract = null; File pathFile = new File(fileName); if (pathFile.exists()) { Path path = Paths.get(fileName); byte[] data = Files.readAllBytes(path); try { if (fromPackedTransaction) { contract = Contract.fromPackedTransaction(data); } else { contract = new Contract(data); } } catch (Quantiser.QuantiserException e) { addError("QUANTIZER_COST_LIMIT", fileName, e.toString()); } } else { addError(Errors.NOT_FOUND.name(), fileName, "Path " + fileName + " does not exist"); } return contract; }  static void main(String[] args); static PrivateKey getPrivateKey(); static BasicHttpClientSession getSession(int nodeNumber); static void breakSession(int nodeNumber); static void clearSession(); static void clearSession(boolean full); static void saveSession(); static void setVerboseMode(boolean verboseMode); static Contract loadContract(String fileName, Boolean fromPackedTransaction); static Parcel loadParcel(String fileName); static Contract loadContract(String fileName); static void exportContract(Contract contract, String fileName, String format, Boolean jsonPretty); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners); static boolean saveContract(Contract contract, String fileName, Boolean fromPackedTransaction, Boolean addSigners, Set<Contract> referencedItems); static boolean saveParcel(Parcel parcel, String fileName); static void saveContract(Contract contract, String fileName); static List<Wallet> findWallets(String path); static HashMap<String, Contract> findContracts(String path); static HashMap<String, Contract> findContracts(String path, Boolean recursively); static List<File> findFiles(String path, Boolean recursively); static Contract downloadContract(String url); static Parcel revokeContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment, PrivateKey... key); @Deprecated static Contract revokeContract(Contract contract, PrivateKey... key); @Deprecated static void registerContract(Contract contract, int waitTime, Boolean fromPackedTransaction); static Parcel prepareForRegisterContract(Contract contract, Contract u, int amount, Set<PrivateKey> uKeys, boolean withTestPayment); static Parcel prepareForRegisterPayingParcel(Contract contract, Contract u, int amount, int amountStorage, Set<PrivateKey> uKeys, boolean withTestPayment); static ItemResult registerParcel(Parcel parcel, int waitTime); static void registerContract(Contract contract); static void registerContract(Contract contract, int waitTime); static void setTestMode(); static void setTestRootPath(String rootPath); static void setNodeNumber(int number); static void setNodeUrl(String url); static void setTopologyFileName(String filename); static void setPrivateKey(PrivateKey key); static Reporter getReporter(); static synchronized ClientNetwork getClientNetwork(); static synchronized Map<String, PrivateKey> keysMap(); static synchronized Map<String, PrivateKey> keysMapContract(); static String DEFAULT_WALLET_PATH; static final String AMOUNT_FIELD_NAME; }