use of com.icodici.universa.contract.services.NContract in project universa by UniversaBlockchain.
the class SmartContractTest method goodSmartContractFromDSL.
@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);
}
use of com.icodici.universa.contract.services.NContract in project universa by UniversaBlockchain.
the class SmartContractTest method serializeSmartContract.
@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);
}
use of com.icodici.universa.contract.services.NContract in project universa by UniversaBlockchain.
the class SmartContractTest method goodSmartContract.
@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);
}
use of com.icodici.universa.contract.services.NContract in project universa by UniversaBlockchain.
the class NSmartContractTest method serializeNSmartContract.
@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);
}
use of com.icodici.universa.contract.services.NContract in project universa by UniversaBlockchain.
the class NSmartContractTest method goodNSmartContract.
@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);
}
Aggregations