use of com.icodici.universa.contract.KeyRecord in project universa by UniversaBlockchain.
the class ListRoleTest method shouldNotPerformRoleWithAllMode.
@Test
public void shouldNotPerformRoleWithAllMode() {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
SimpleRole s2 = new SimpleRole("owner2");
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
s2.addKeyRecord(new KeyRecord(keys.get(1).getPublicKey()));
c.registerRole(s1);
c.registerRole(s2);
ListRole roleList = new ListRole("listAllMode", ListRole.Mode.ALL, Do.listOf(s1, s2));
HashSet<AbstractKey> keys = new HashSet<>(Do.listOf(ListRoleTest.keys.get(1).getPublicKey()));
assertFalse(roleList.isAllowedForKeys(keys));
}
use of com.icodici.universa.contract.KeyRecord in project universa by UniversaBlockchain.
the class ListRoleTest method shouldNotPerformRoleWithAnyMode.
@Test
public void shouldNotPerformRoleWithAnyMode() {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
SimpleRole s2 = new SimpleRole("owner2");
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
s2.addKeyRecord(new KeyRecord(keys.get(2).getPublicKey()));
c.registerRole(s1);
c.registerRole(s2);
ListRole roleList = new ListRole("listAnyMode");
roleList.setMode(ListRole.Mode.ANY);
roleList.addRole(s1).addRole(s2);
assertFalse(roleList.isAllowedForKeys(new HashSet<>(Do.listOf(keys.get(1).getPublicKey()))));
}
use of com.icodici.universa.contract.KeyRecord in project universa by UniversaBlockchain.
the class ListRoleTest method serializeAny.
@Test
public void serializeAny() throws Exception {
SimpleRole s1 = new SimpleRole("owner");
SimpleRole s2 = new SimpleRole("owner2");
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
s2.addKeyRecord(new KeyRecord(keys.get(2).getPublicKey()));
ListRole roleList = new ListRole("listAnyMode", ListRole.Mode.ANY, Do.listOf(s1, s2));
Binder serialized = DefaultBiMapper.serialize(roleList);
Role r1 = DefaultBiMapper.deserialize(serialized);
assertEquals(r1, roleList);
}
use of com.icodici.universa.contract.KeyRecord in project universa by UniversaBlockchain.
the class ListRoleTest method serializeAll.
@Test
public void serializeAll() throws Exception {
Contract c = new Contract();
SimpleRole s1 = new SimpleRole("owner");
s1.addRequiredReference("refName", Role.RequiredMode.ALL_OF);
s1.addKeyRecord(new KeyRecord(keys.get(0).getPublicKey()));
ListRole roleList = new ListRole("listAllMode", ListRole.Mode.ALL, Do.listOf(s1));
c.registerRole(s1);
c.registerRole(roleList);
Binder serialized = DefaultBiMapper.serialize(roleList);
Role r1 = DefaultBiMapper.deserialize(serialized);
assertEquals(r1, roleList);
}
use of com.icodici.universa.contract.KeyRecord 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));
}
Aggregations