use of com.icodici.universa.contract.Contract in project universa by UniversaBlockchain.
the class ListRoleTest method shouldPerformRoleWithQuorumMode.
@Test
public void shouldPerformRoleWithQuorumMode() {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
SimpleRole s2 = new SimpleRole("owner2");
SimpleRole s3 = new SimpleRole("owner3");
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
s2.addKeyRecord(new KeyRecord(keys.get(2).getPublicKey()));
s3.addKeyRecord(new KeyRecord(keys.get(3).getPublicKey()));
c.registerRole(s1);
c.registerRole(s2);
c.registerRole(s3);
ListRole roleList = new ListRole("listQuorumMode", 2, Do.listOf(s1, s3, s2));
HashSet<AbstractKey> keys = new HashSet<>(Do.listOf(ListRoleTest.keys.get(0).getPublicKey(), ListRoleTest.keys.get(2).getPublicKey()));
assertTrue(roleList.isAllowedForKeys(keys));
}
use of com.icodici.universa.contract.Contract in project universa by UniversaBlockchain.
the class ListRoleTest method shouldPerformRoleWithAnyMode.
@Test
public void shouldPerformRoleWithAnyMode() {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
SimpleRole s2 = new SimpleRole("owner2");
s1.addKeyRecord(new KeyRecord(keys.get(1).getPublicKey()));
s2.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
c.registerRole(s1);
c.registerRole(s2);
ListRole roleList = new ListRole("listAnyMode", ListRole.Mode.ANY, Do.listOf(s1, s2));
assertTrue(roleList.isAllowedForKeys(new HashSet<>(Do.listOf(keys.get(1).getPublicKey()))));
}
use of com.icodici.universa.contract.Contract in project universa by UniversaBlockchain.
the class RoleLinkTest method detectsCirculars.
@Test
public void detectsCirculars() throws Exception {
Contract c = new Contract();
RoleLink r1 = new RoleLink("bar", "foo");
RoleLink r2 = new RoleLink("foo", "bar");
c.registerRole(r1);
c.registerRole(r2);
assertNull(r2.resolve());
}
use of com.icodici.universa.contract.Contract in project universa by UniversaBlockchain.
the class RoleLinkTest method resolve.
@Test
public void resolve() throws Exception {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
c.registerRole(s1);
RoleLink r1 = new RoleLink("lover", "owner");
c.registerRole(r1);
RoleLink r2 = r1.linkAs("mucker");
assertSame(s1, s1.resolve());
assertSame(s1, r1.resolve());
assertSame(s1, r2.resolve());
}
use of com.icodici.universa.contract.Contract in project universa by UniversaBlockchain.
the class CLIMain method revokeContract.
/**
* Revoke specified contract and create a revocation transactional contract.
*
* @param contract
*
* @return Parcel - revoking transaction contract.
*/
public static Parcel revokeContract(Contract contract, Contract tu, int amount, Set<PrivateKey> tuKeys, boolean withTestPayment, PrivateKey... key) throws IOException {
report("keys num: " + key.length);
Contract tc = ContractsService.createRevocation(contract, key);
Parcel parcel = registerContract(tc, tu, amount, tuKeys, withTestPayment, 0);
return parcel;
}
Aggregations