@Test public void checkStateTwoHashes3() throws Exception { callMain2("--probe", "--verbose", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ", "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA"); }
@Test public void extraChecks() throws Exception { callMain2("-v", "--check", "/Users/sergeych/dev/!/0199efcd-0313-4e2c-8f19-62d6bd1c9755.transaction"); }
@Test public void checkStateTwoHashes1() throws Exception { callMain2("--probe", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ", "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA", "--verbose"); }
@Test public void checkStateTwoHashes4() throws Exception { callMain2("--probe", "--verbose", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ" + "," + "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA"); }
@Test public void unpackContractWithCounterParts() throws Exception { String fileName = basePath + "packedContract.unicon"; callMain2("--check", fileName, "-v"); callMain2("-unpack", fileName, "-v"); // System.out.println(" "); // callMain2("--check", basePath + "packedContract_new_item_1.unicon", "-v"); // System.out.println(" "); // callMain("--check", basePath + "packedContract_revoke_1.unicon", "-v"); System.out.println(output); assertEquals(0, errors.size()); }
@Test public void unpackParcel() throws Exception { String fileName = basePath + "packedContract.uniparcel"; callMain2("--check", fileName, "-v"); callMain2("-unpack", fileName, "-v"); // System.out.println(" "); // callMain2("--check", basePath + "packedContract_new_item_1.unicon", "-v"); // System.out.println(" "); // callMain("--check", basePath + "packedContract_revoke_1.unicon", "-v"); System.out.println(output); assertEquals(0, errors.size()); }
@Test public void checkStateTwoHashes2() throws Exception { callMain2("--probe", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ" + "," + "G0lCqE2TPn9wiioHDy5nllWbLkRwPA97HdnhtcCn3EDAuoDBwiZcRIGjrBftGLFWOVUY8D5yPVkEj+wqb6ytrA", "--verbose"); }
@Test public void checkState() throws Exception { callMain2("--probe", "py2GSOxgOGBPiaL9rnGm800lf1Igk3/BGU/wSawFNic7H/x0r8KPOb61iqYlDXWMtR44r5GaO/EDa5Di8c6lmQ", "--verbose"); }
@Test public void createAndRegisterShareFromDSL() throws Exception { String uContract = getApprovedUContract(); callMain2("-create", rootPath + "ShareDSLTemplate.yml", "--output", basePath + "realShare.unicon", "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey"); assertTrue (new File(basePath + "realShare.unicon").exists()); callMain("--register", basePath + "realShare.unicon", "--u", uContract, "-k", rootPath + "keys/stepan_mamontov.private.unikey", "--wait", "3000"); System.out.println(output); assertTrue (output.indexOf(ItemState.APPROVED.name()) >= 0); }
@Test public void createAndRegisterTokenFromDSL() throws Exception { // You have a token dsl and want to release own tokens String uContract = getApprovedUContract(); callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "realToken.unicon", "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey"); assertTrue (new File(basePath + "realToken.unicon").exists()); callMain("-register", basePath + "realToken.unicon", "-u", uContract, "-k", rootPath + "keys/stepan_mamontov.private.unikey", "-wait", "2000"); System.out.println(output); assertTrue (output.indexOf(ItemState.APPROVED.name()) >= 0); }
@Test public void createAndRegisterNotaryContractWithFileFromDSL() throws Exception { String uContract = getApprovedUContract(); callMain2("-create", rootPath + "notaryContractWithFile.yaml", "--output", basePath + "realNotaryContractWithFile.unicon", "-k", rootPath + "keys/marty_mcfly.private.unikey"); assertTrue (new File(basePath + "realNotaryContractWithFile.unicon").exists()); callMain("--register", basePath + "realNotaryContractWithFile.unicon", "--u", uContract, "-k", rootPath + "keys/stepan_mamontov.private.unikey", "--wait", "1000"); System.out.println(output); assertTrue (output.indexOf(ItemState.APPROVED.name()) >= 0); }
@Test public void createAndRegisterNotaryFromDSL() throws Exception { // You have a notary dsl and want to release notarized document for someone String uContract = getApprovedUContract(); callMain2("-create", rootPath + "NotaryDSLTemplate.yml", "--output", basePath + "realNotary.unicon", "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey"); assertTrue (new File(basePath + "realNotary.unicon").exists()); callMain("--register", basePath + "realNotary.unicon", "--u", uContract, "-k", rootPath + "keys/stepan_mamontov.private.unikey", "--wait", "1000"); System.out.println(output); assertTrue (output.indexOf(ItemState.APPROVED.name()) >= 0); }
@Test public void createRegisterCheckRevoke() throws Exception { String keyFileName = rootPath + "_xer0yfe2nn1xthc.private.unikey"; String contractFileName = basePath + "contract7.unicon"; callMain("-c", rootPath + "simple_root_contract_v2.yml", "-k", keyFileName, "--output", contractFileName ); assertTrue(new File(contractFileName).exists()); assertEquals(0, errors.size()); Contract c = Contract.fromSealedFile(contractFileName); System.out.println(c.getId()); // callMain2("--ch", contractFileName, "--verbose"); callMain2("--register", contractFileName, "--verbose"); for (int i = 0; i < 10; i++) { callMain2("--probe", c.getId().toBase64String()); Thread.sleep(500); } }
@Ignore("use with real network and own U") @Test public void fireRegister() throws Exception { // // try to register with payment callMain2("--register", rootPath + "root5.unicon", "--u", rootPath + "UUP.unicon", "-k", rootPath + "UKey.private.unikey", // "-utest", "-wait", "15000", "-v"); // try to register without payment callMain("--register", rootPath + "root5.unicon", "-wait", "15000", "-v"); System.out.println(output); assertTrue (output.indexOf("payment contract or private keys for payment contract is missing") >= 0); }
@Test public void revokeContractWithoutKey() throws Exception { String contractFileName = basePath + "contract_for_revoke1.unicon"; String uContract = getApprovedUContract(); callMain2("--register", contractFileName, "--verbose", "--u", uContract, "--k", rootPath + "keys/stepan_mamontov.private.unikey"); callMain2("-revoke", contractFileName, "-v"); Thread.sleep(1500); System.out.println("probe after revoke"); Contract c = CLIMain.loadContract(contractFileName); callMain("--probe", c.getId().toBase64String(), "--verbose"); System.out.println(output); assertEquals(0, errors.size()); assertTrue (output.indexOf(ItemState.REVOKED.name()) < 0); }
@Test public void createRegisterTwoContractsCheckRevoke4() throws Exception { String keyFileName = rootPath + "_xer0yfe2nn1xthc.private.unikey"; callMain("-c", rootPath + "simple_root_contract_v2.yml", "-k", keyFileName, "--output", basePath + "simple_root_contract_v2.unicon" ); String contractFileName = basePath + "simple_root_contract_v2.unicon"; assertTrue(new File(contractFileName).exists()); assertEquals(0, errors.size()); callMain("-c", rootPath + "another_root_contract_v2.yml", "-k", keyFileName, "--output", basePath + "another_root_contract_v2.unicon" ); String contractFileName2 = basePath + "another_root_contract_v2.unicon"; assertTrue(new File(contractFileName2).exists()); assertEquals(0, errors.size()); Contract c = Contract.fromSealedFile(contractFileName); System.out.println("first contract: " + c.getId()); Contract c2 = Contract.fromSealedFile(contractFileName2); System.out.println("second contract: " + c.getId()); callMain2("--register", "--verbose", contractFileName + "," + contractFileName2); }
@Test public void packContractWithCounterParts() throws Exception { String contractFileName = basePath + "coin1000.unicon"; Contract contract = createCoin(); contract.getStateData().set(FIELD_NAME, new Decimal(1000)); contract.addSignerKeyFromFile(PRIVATE_KEY_PATH); contract.seal(); CLIMain.saveContract(contract, contractFileName); callMain2("--check", contractFileName, "-v"); callMain2("-pack-with", contractFileName, "-add-sibling", basePath + "packedContract_new_item.unicon", "-add-revoke", basePath + "packedContract_revoke.unicon", "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey", "-v"); callMain("--check", contractFileName, "-v"); System.out.println(output); // assertEquals(0, errors.size()); }
@Test public void packContractWithCounterPartsWithName() throws Exception { String contractFileName = basePath + "coin100.unicon"; String savingFileName = basePath + "packed.unicon"; Contract contract = createCoin(); contract.getStateData().set(FIELD_NAME, new Decimal(100)); contract.addSignerKeyFromFile(PRIVATE_KEY_PATH); contract.seal(); CLIMain.saveContract(contract, contractFileName); callMain2("--check", contractFileName, "-v"); callMain2("-pack-with", contractFileName, "-add-sibling", basePath + "contract2.unicon", "-add-revoke", basePath + "contract_for_revoke1.unicon", "--output", savingFileName, "-v"); callMain("--check", savingFileName, "-v"); System.out.println(output); // assertEquals(0, errors.size()); }
@Test public void anonymizeRole() throws Exception { callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing.unicon", "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey"); assertTrue (new File(basePath + "forRoleAnonymizing.unicon").exists()); callMain("-anonymize", basePath + "forRoleAnonymizing.unicon", "-role", "issuer"); assertTrue (new File(basePath + "forRoleAnonymizing_anonymized.unicon").exists()); System.out.println(output); PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey")); Contract contract = CLIMain.loadContract(basePath + "forRoleAnonymizing_anonymized.unicon", true); assertFalse(contract.getIssuer().getKeys().contains(key.getPublicKey())); Contract anonPublishedContract = new Contract(contract.getLastSealedBinary()); assertFalse(anonPublishedContract.getIssuer().getKeys().contains(key.getPublicKey())); assertFalse(anonPublishedContract.getSealedByKeys().contains(key.getPublicKey())); }
@Test public void anonymizeRoleAndSaveWithName() throws Exception { callMain2("-create", rootPath + "TokenDSLTemplate.yml", "--output", basePath + "forRoleAnonymizing.unicon", "-k", rootPath + "_xer0yfe2nn1xthc.private.unikey"); assertTrue (new File(basePath + "forRoleAnonymizing.unicon").exists()); callMain("-anonymize", basePath + "forRoleAnonymizing.unicon", "-role", "issuer", "--output", basePath + "myAnon.unicon"); assertTrue (new File(basePath + "myAnon.unicon").exists()); System.out.println(output); PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey")); Contract contract = CLIMain.loadContract(basePath + "myAnon.unicon", true); assertFalse(contract.getIssuer().getKeys().contains(key.getPublicKey())); Contract anonPublishedContract = new Contract(contract.getLastSealedBinary()); assertFalse(anonPublishedContract.getIssuer().getKeys().contains(key.getPublicKey())); assertFalse(anonPublishedContract.getSealedByKeys().contains(key.getPublicKey())); }