if(getDefinition().getExtendedType() == null || !getDefinition().getExtendedType().equals(SmartContractType.FOLLOWER1.name())) getDefinition().setExtendedType(SmartContractType.FOLLOWER1.name());
if(getDefinition().getExtendedType() == null || !getDefinition().getExtendedType().equals(SmartContractType.SLOT1.name())) getDefinition().setExtendedType(SmartContractType.SLOT1.name());
if(getDefinition().getExtendedType() == null || !getDefinition().getExtendedType().equals(SmartContractType.UNS1.name())) getDefinition().setExtendedType(SmartContractType.UNS1.name());
assertTrue(smartContract.isOk()); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), smartContract.get("definition.extended_type"));
assertSameContracts(smartContract, desContract); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), desContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), desContract.get("definition.extended_type")); assertSameContracts(smartContract, copiedContract); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), copiedContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), copiedContract.get("definition.extended_type"));
assertTrue(uns.isOk()); assertEquals(NSmartContract.SmartContractType.UNS1.name(), uns.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.UNS1.name(), uns.get("definition.extended_type"));
assertTrue(smartContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), smartContract.get("definition.extended_type"));
assertTrue(smartContract.isOk()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.SLOT1.name(), smartContract.get("definition.extended_type"));
assertTrue(smartContract.isOk()); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.FOLLOWER1.name(), smartContract.get("definition.extended_type"));
@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); } }
@Test public void goodUnsContractFromDSL() throws Exception { PrivateKey authorizedNameServiceKey = TestKeys.privateKey(3); config.setAuthorizedNameServiceCenterKeyData(new Bytes(authorizedNameServiceKey.getPublicKey().pack())); Contract paymentDecreased = createUnsPayment(); UnsContract uns = UnsContract.fromDslFile(rootPath + "uns/simple_uns_contract.yml"); uns.setNodeInfoProvider(nodeInfoProvider); uns.addSignerKeyFromFile(rootPath + "_xer0yfe2nn1xthc.private.unikey"); uns.addSignerKey(authorizedNameServiceKey); uns.addNewItems(paymentDecreased); uns.seal(); uns.check(); uns.traceErrors(); assertTrue(uns.isOk()); assertEquals(NSmartContract.SmartContractType.UNS1.name(), uns.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.UNS1.name(), uns.get("definition.extended_type")); assertTrue(uns instanceof UnsContract); assertTrue(uns instanceof NSmartContract); assertTrue(uns instanceof NContract); }
@Test public void goodNSmartContractFromDSL() throws Exception { Contract smartContract = NSmartContract.fromDslFile(ROOT_PATH + "NotaryNSmartDSLTemplate.yml"); smartContract.addSignerKeyFromFile(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey"); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); registerAndCheckApproved(smartContract); ItemResult itemResult = node.waitItem(smartContract.getId(), 8000); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onCreatedResult").getString("status", null)); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onUpdateResult").getString("status", null)); }
@Test public void goodSmartContractFromDSL() throws Exception { Contract smartContract = NSmartContract.fromDslFile(ROOT_PATH + "NotarySmartDSLTemplate.yml"); smartContract.addSignerKeyFromFile(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey"); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); registerAndCheckApproved(smartContract); ItemResult itemResult = node.waitItem(smartContract.getId(), 8000); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onCreatedResult").getString("status", null)); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onUpdateResult").getString("status", null)); }
@Test public void goodSmartContract() throws Exception { final PrivateKey key = new PrivateKey(Do.read(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey")); Contract smartContract = new NSmartContract(key); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); registerAndCheckApproved(smartContract); ItemResult itemResult = node.waitItem(smartContract.getId(), 8000); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onCreatedResult").getString("status", null)); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onUpdateResult").getString("status", null)); }
@Test public void goodNSmartContract() throws Exception { final PrivateKey key = new PrivateKey(Do.read(ROOT_PATH + "_xer0yfe2nn1xthc.private.unikey")); Contract smartContract = new NSmartContract(key); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); registerAndCheckApproved(smartContract); ItemResult itemResult = node.waitItem(smartContract.getId(), 8000); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onCreatedResult").getString("status", null)); // assertEquals("ok", itemResult.extraDataBinder.getBinder("onUpdateResult").getString("status", null)); }
@Test public void goodSmartContractFromDSL() throws Exception { Contract smartContract = NSmartContract.fromDslFile(rootPath + "NotarySmartDSLTemplate.yml"); smartContract.addSignerKeyFromFile(rootPath + "_xer0yfe2nn1xthc.private.unikey"); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); }
@Test public void goodNSmartContractFromDSL() throws Exception { Contract smartContract = NSmartContract.fromDslFile(rootPath + "NotaryNSmartDSLTemplate.yml"); smartContract.addSignerKeyFromFile(rootPath + "_xer0yfe2nn1xthc.private.unikey"); smartContract.seal(); smartContract.check(); smartContract.traceErrors(); assertTrue(smartContract.isOk()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); }
@Test public void goodSmartContract() 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()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); }
@Test public void goodNSmartContract() 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()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.getDefinition().getExtendedType()); assertEquals(NSmartContract.SmartContractType.N_SMART_CONTRACT.name(), smartContract.get("definition.extended_type")); assertTrue(smartContract instanceof NSmartContract); assertTrue(smartContract instanceof NContract); }