Search in sources :

Example 16 with Binder

use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.

the class PermissionsTest method validPermissionIds.

@Test
public void validPermissionIds() throws Exception {
    Contract c = Contract.fromDslFile(ROOT_CONTRACT);
    c.addSignerKeyFromFile(PRIVATE_KEY_PATH);
    byte[] sealed = c.seal();
    assertTrue(c.check());
    Binder s = DefaultBiMapper.serialize(c);
    s.getBinderOrThrow("definition", "permissions");
}
Also used : Binder(net.sergeych.tools.Binder) Test(org.junit.Test)

Example 17 with Binder

use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.

the class PermissionsTest method shouldModifyDescNullStateDataValues.

@Test
public void shouldModifyDescNullStateDataValues() throws Exception {
    PrivateKey ownerKey2 = TestKeys.privateKey(1);
    Contract c = basicContractCreation(SUBSCRIPTION_WITH_DATA, PRIVATE_KEY, ownerKey2);
    Binder d = c.getStateData();
    Contract c1 = c.createRevision(ownerKey2);
    Binder d1 = c1.getStateData();
    final String oldValue = "An example of smart contract.";
    final String newValue = null;
    final String field = "description";
    setAndCheckOldNewValues(d, d1, oldValue, newValue, field);
    sealCheckTrace(c1, true);
}
Also used : Binder(net.sergeych.tools.Binder) PrivateKey(com.icodici.crypto.PrivateKey) Test(org.junit.Test)

Example 18 with Binder

use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.

the class PermissionsTest method shouldNotModifySeveralStateDataValues.

@Test
public void shouldNotModifySeveralStateDataValues() throws Exception {
    PrivateKey ownerKey2 = TestKeys.privateKey(1);
    Contract c = basicContractCreation(SUBSCRIPTION_WITH_DATA, PRIVATE_KEY, ownerKey2);
    Binder d = c.getStateData();
    Contract c1 = c.createRevision(ownerKey2);
    Binder d1 = c1.getStateData();
    String oldValue = "An example of smart contract.";
    String newValue = "UniversaSmartContract";
    String field = "description";
    setAndCheckOldNewValues(d, d1, oldValue, newValue, field);
    oldValue = "blockchain-partnership.";
    newValue = "blockchain-universa.";
    field = "partner_name";
    setAndCheckOldNewValues(d, d1, oldValue, newValue, field);
    d1.addToInt("transactional_units_left", -50);
    d1.addToInt("direction", 5);
    d1.addToInt("option", -1);
    sealCheckTrace(c1, false);
}
Also used : Binder(net.sergeych.tools.Binder) PrivateKey(com.icodici.crypto.PrivateKey) Test(org.junit.Test)

Example 19 with Binder

use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.

the class PermissionsTest method shouldNotModifyStateDataValues.

@Test
public void shouldNotModifyStateDataValues() throws Exception {
    PrivateKey ownerKey2 = TestKeys.privateKey(1);
    Contract c = basicContractCreation(SUBSCRIPTION_WITH_DATA, PRIVATE_KEY, ownerKey2);
    Binder d = c.getStateData();
    Contract c1 = c.createRevision(ownerKey2);
    Binder d1 = c1.getStateData();
    final String oldValue = "1";
    final String newValue = "2";
    final String field = "option";
    setAndCheckOldNewValues(d, d1, oldValue, newValue, field);
    sealCheckTrace(c1, false);
}
Also used : Binder(net.sergeych.tools.Binder) PrivateKey(com.icodici.crypto.PrivateKey) Test(org.junit.Test)

Example 20 with Binder

use of net.sergeych.tools.Binder in project universa by UniversaBlockchain.

the class PermissionsTest method shouldPopulateWithEmptyStateDataValues.

@Test
public void shouldPopulateWithEmptyStateDataValues() throws Exception {
    PrivateKey ownerKey2 = TestKeys.privateKey(1);
    Contract c = basicContractCreation(SUBSCRIPTION_WITH_DATA, PRIVATE_KEY, ownerKey2);
    Binder d = c.getStateData();
    Contract c1 = c.createRevision(ownerKey2);
    Binder d1 = c1.getStateData();
    final String oldValue = "An example of smart contract.";
    final String newValue = "";
    final String field = "description";
    setAndCheckOldNewValues(d, d1, oldValue, newValue, field);
    sealCheckTrace(c1, true);
}
Also used : Binder(net.sergeych.tools.Binder) PrivateKey(com.icodici.crypto.PrivateKey) Test(org.junit.Test)

Aggregations

Binder (net.sergeych.tools.Binder)136 Test (org.junit.Test)67 PrivateKey (com.icodici.crypto.PrivateKey)21 Contract (com.icodici.universa.contract.Contract)14 PublicKey (com.icodici.crypto.PublicKey)13 IOException (java.io.IOException)11 KeyRecord (com.icodici.universa.contract.KeyRecord)10 SimpleRole (com.icodici.universa.contract.roles.SimpleRole)10 Yaml (org.yaml.snakeyaml.Yaml)9 Bytes (net.sergeych.utils.Bytes)8 Decimal (com.icodici.universa.Decimal)7 ListRole (com.icodici.universa.contract.roles.ListRole)6 NonNull (org.checkerframework.checker.nullness.qual.NonNull)5 Gson (com.google.gson.Gson)4 GsonBuilder (com.google.gson.GsonBuilder)4 XStream (com.thoughtworks.xstream.XStream)4 DomDriver (com.thoughtworks.xstream.io.xml.DomDriver)4 List (java.util.List)4 RoleLink (com.icodici.universa.contract.roles.RoleLink)3 ItemResult (com.icodici.universa.node.ItemResult)3