Search in sources :

Example 1 with NContract

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);
}
Also used : NSmartContract(com.icodici.universa.contract.services.NSmartContract) NContract(com.icodici.universa.contract.services.NContract) NContract(com.icodici.universa.contract.services.NContract) NSmartContract(com.icodici.universa.contract.services.NSmartContract) Test(org.junit.Test)

Example 2 with 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);
}
Also used : Binder(net.sergeych.tools.Binder) NSmartContract(com.icodici.universa.contract.services.NSmartContract) PrivateKey(com.icodici.crypto.PrivateKey) NContract(com.icodici.universa.contract.services.NContract) NContract(com.icodici.universa.contract.services.NContract) NSmartContract(com.icodici.universa.contract.services.NSmartContract) Test(org.junit.Test)

Example 3 with 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);
}
Also used : NSmartContract(com.icodici.universa.contract.services.NSmartContract) PrivateKey(com.icodici.crypto.PrivateKey) NContract(com.icodici.universa.contract.services.NContract) NContract(com.icodici.universa.contract.services.NContract) NSmartContract(com.icodici.universa.contract.services.NSmartContract) Test(org.junit.Test)

Example 4 with 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);
}
Also used : Binder(net.sergeych.tools.Binder) NSmartContract(com.icodici.universa.contract.services.NSmartContract) PrivateKey(com.icodici.crypto.PrivateKey) NContract(com.icodici.universa.contract.services.NContract) NContract(com.icodici.universa.contract.services.NContract) NSmartContract(com.icodici.universa.contract.services.NSmartContract) Test(org.junit.Test)

Example 5 with 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);
}
Also used : NSmartContract(com.icodici.universa.contract.services.NSmartContract) PrivateKey(com.icodici.crypto.PrivateKey) NContract(com.icodici.universa.contract.services.NContract) NContract(com.icodici.universa.contract.services.NContract) NSmartContract(com.icodici.universa.contract.services.NSmartContract) Test(org.junit.Test)

Aggregations

NContract (com.icodici.universa.contract.services.NContract)6 NSmartContract (com.icodici.universa.contract.services.NSmartContract)6 Test (org.junit.Test)6 PrivateKey (com.icodici.crypto.PrivateKey)4 Binder (net.sergeych.tools.Binder)2