use of com.icodici.crypto.AbstractKey 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.crypto.AbstractKey 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.crypto.AbstractKey in project universa by UniversaBlockchain.
the class ListRoleTest method shouldNotPerformRoleWithQuorumMode.
@Test
public void shouldNotPerformRoleWithQuorumMode() {
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("listQuorumMode");
roleList.setQuorum(2);
roleList.addAll(Do.listOf(s1, s2));
c.registerRole(roleList);
HashSet<AbstractKey> keys = new HashSet<>(Do.listOf(ListRoleTest.keys.get(1).getPublicKey()));
assertFalse(roleList.isAllowedForKeys(keys));
}
use of com.icodici.crypto.AbstractKey in project universa by UniversaBlockchain.
the class ListRoleTest method shouldPerformRoleWithAllMode.
@Test
public void shouldPerformRoleWithAllMode() {
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");
roleList.setMode(ListRole.Mode.ALL);
roleList.addRole(s1).addRole(s2);
HashSet<AbstractKey> keys = new HashSet<>(Do.listOf(ListRoleTest.keys.get(0).getPublicKey(), ListRoleTest.keys.get(1).getPublicKey()));
assertTrue(roleList.isAllowedForKeys(keys));
}
Aggregations