/** * Get all addresses, used by registered role from the contract. For public keys returns addresses too. * @return list of strings with addresses */ @Deprecated public List<String> getRoleAddresses(String roleName) { return getRole(roleName).getAllAddresses(); }
@Test public void getAllAddresses() throws Exception { Contract contract = new Contract(TestKeys.privateKey(0)); ListRole owner = new ListRole("owner"); owner.addRole(new SimpleRole("owner", Arrays.asList(TestKeys.publicKey(0), TestKeys.publicKey(1)))); owner.addRole(new SimpleRole("owner", Arrays.asList(TestKeys.publicKey(2).getLongAddress()))); owner.addRole(new SimpleRole("owner", Arrays.asList(TestKeys.publicKey(3).getShortAddress(), TestKeys.publicKey(4)))); contract.registerRole(owner); List<String> addresses = contract.getRole("owner").getAllAddresses(); System.out.println("owner: " + addresses); for (String addr : addresses) assertThat(addr, Matchers.anyOf( Matchers.equalTo(TestKeys.publicKey(0).getShortAddress().toString()), Matchers.equalTo(TestKeys.publicKey(1).getShortAddress().toString()), Matchers.equalTo(TestKeys.publicKey(2).getLongAddress().toString()), Matchers.equalTo(TestKeys.publicKey(3).getShortAddress().toString()), Matchers.equalTo(TestKeys.publicKey(4).getShortAddress().toString()) )); }