@Override protected Object clone() throws CloneNotSupportedException { return copy(); }
private Contract joinAndRemoveFromContracts(List<Contract> selectedContracts) throws Exception { Contract result = selectedContracts.get(0).copy(); result.getRevokingItems().addAll(selectedContracts); this.contracts.removeAll(selectedContracts); result.setKeysToSignWith(selectedContracts.get(0).getKeysToSignWith()); return result; }
Contract newRevision = copy();
for (int i = 0; i < count; i++) { Contract c = copy();
@Test public void serializeToBinder() throws Exception { Contract c = Contract.fromDslFile(rootPath + "simple_root_contract.yml"); Binder b = BossBiMapper.serialize(c); Contract c1 = DefaultBiMapper.deserialize(b); // System.out.println(yaml.dump(b)); // System.out.println(yaml.dump(c1.serializeToBinder())); assertProperSimpleRootContract(c1); Contract c2 = c.copy(); assertProperSimpleRootContract(c2); }
@Test public void dupesWrongTest() throws Exception { PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey")); Set<PrivateKey> keys = new HashSet<>(); keys.add(key); Contract c_1 = Contract.fromDslFile(rootPath + "coin100.yml"); c_1.addSignerKey(key); c_1.seal(); assertTrue(c_1.check()); c_1.traceErrors(); Contract c_2_1 = ContractsService.createSplit(c_1, new BigDecimal("20"), "amount", keys); Contract c_2_2 = c_2_1.getNew().get(0); if(c_2_2 != null) { Contract c_2_3 = c_2_2.copy(); c_2_3.addSignerKey(key); c_2_3.seal(); c_2_1.addNewItems(c_2_3); } assertEquals(2, c_2_1.getNewItems().size()); c_2_1.check(); c_2_1.traceErrors(); assertFalse(c_2_1.isOk()); // should be BAD_VALUE duplicated revision id assertEquals(2, c_2_1.getErrors().size()); }
assertTrue(((FollowerContract) desContract).isCallbackURLUsed("http://localhost:7777/follow.callback")); Contract copiedContract = smartContract.copy(); assertSameContracts(smartContract, copiedContract);
Contract copiedContract = smartContract.copy(); assertSameContracts(smartContract, copiedContract); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), copiedContract.getDefinition().getExtendedType());
@Test public void serializeSmartContract() throws Exception { final PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey")); Contract smartContract = new NSmartContract(key); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); Binder b = BossBiMapper.serialize(smartContract); Contract desContract = DefaultBiMapper.deserialize(b); assertSameContracts(smartContract, desContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), desContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), desContract.get("definition.extended_type")); assertTrue(desContract instanceof NSmartContract); assertTrue(desContract instanceof NContract); Contract copiedContract = smartContract.copy(); assertSameContracts(smartContract, copiedContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), copiedContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), copiedContract.get("definition.extended_type")); assertTrue(copiedContract instanceof NSmartContract); assertTrue(copiedContract instanceof NContract); } }
@Test public void serializeNSmartContract() throws Exception { final PrivateKey key = new PrivateKey(Do.read(rootPath + "_xer0yfe2nn1xthc.private.unikey")); Contract smartContract = new NSmartContract(key); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); Binder b = BossBiMapper.serialize(smartContract); Contract desContract = DefaultBiMapper.deserialize(b); assertSameContracts(smartContract, desContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), desContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), desContract.get("definition.extended_type")); assertTrue(desContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); Contract copiedContract = smartContract.copy(); assertSameContracts(smartContract, copiedContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), copiedContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), copiedContract.get("definition.extended_type")); assertTrue(copiedContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); } }