/** * Register a specified contract. * * @param contract must be a sealed binary file. */ public static void registerContract(Contract contract) throws IOException { registerContract(contract, 0, true); }
/** * Register a specified contract. * * @param contract must be a sealed binary file. * @param waitTime - wait time for responce. */ public static void registerContract(Contract contract, int waitTime) throws IOException { registerContract(contract, waitTime, true); }
/** * Revoke specified contract and create a revocation transactional contract. * * @param contract * * @return Contract - revoking transaction contract. */ @Deprecated public static Contract revokeContract(Contract contract, PrivateKey... key) throws IOException { report("keys num: " + key.length); Contract tc = ContractsService.createRevocation(contract, key); registerContract(tc, 0, true); return tc; }
@Test public void probeFile() throws Exception { Contract c = Contract.fromDslFile(rootPath + "simple_root_contract.yml"); c.addSignerKeyFromFile(rootPath+"_xer0yfe2nn1xthc.private.unikey"); c.addSignerKeyFromFile(rootPath + "keys/u_key.private.unikey"); PrivateKey goodKey = c.getKeysToSignWith().iterator().next(); // let's make this key among owners ((SimpleRole)c.getRole("owner")).addKeyRecord(new KeyRecord(goodKey.getPublicKey())); c.seal(); Files.write(Paths.get(basePath + "probeFile.unicon"),c.getPackedTransaction(), StandardOpenOption.CREATE, StandardOpenOption.WRITE); System.out.println("---"); System.out.println("register contract"); System.out.println("---"); CLIMain.registerContract(c); Thread.sleep(1500); System.out.println("---"); System.out.println("check contract"); System.out.println("---"); callMain("--probe-file", basePath + "probeFile.unicon"); System.out.println(output); assertTrue (output.indexOf(ItemState.APPROVED.name()) >= 0); }
CLIMain.registerContract(c); CLIMain.registerContract(c); CLIMain.registerContract(c); CLIMain.registerContract(c);
try { CLIMain.registerContract(contract); ItemResult r1 = clientNetwork1.register(contract.getPackedTransaction(), 50); try { CLIMain.registerContract(contract); ItemResult r2 = clientNetwork2.register(contract.getPackedTransaction(), 50); try { CLIMain.registerContract(contract); ItemResult r3 = clientNetwork3.register(contract.getPackedTransaction(), 50);
System.out.println("---"); CLIMain.registerContract(c); System.out.println("---"); CLIMain.registerContract(tc);