Search in sources :

Example 1 with AddressListConverter

use of org.aion.rpc.types.RPCTypesConverter.AddressListConverter in project aion by aionnetwork.

the class PersonalRPCImplTest method testPersonal_ListAccounts.

@Test
public void testPersonal_ListAccounts() {
    List<AionAddress> address = new ArrayList<>();
    AccountManager accountManager = new AccountManager(AionLoggerFactory.getLogger(LogEnum.API.name()));
    int addressCount = 3;
    for (int i = 0; i < addressCount; i++) {
        address.add(accountManager.createAccount("password"));
    }
    chainHolder = spy(new AionChainHolder(AionImpl.instForTest(), accountManager));
    doCallRealMethod().when(chainHolder).listAccounts();
    rpc = spy(new RPCMethods(chainHolder));
    doCallRealMethod().when(rpc).personal_listAccounts();
    Request request = new Request(idGenerator.generateID(), listAccountMethod, null, VersionType.Version2);
    List<AionAddress> aionAddressList = execute(request, AddressListConverter::decode);
    verify(chainHolder, atLeastOnce()).listAccounts();
    assertEquals(addressCount, aionAddressList.size());
    // check that we get all
    assertEquals(Set.copyOf(address), Set.copyOf(aionAddressList));
// the expected addresses
}
Also used : AionAddress(org.aion.types.AionAddress) ArrayList(java.util.ArrayList) Request(org.aion.rpc.types.RPCTypes.Request) AccountManager(org.aion.api.server.account.AccountManager) AddressListConverter(org.aion.rpc.types.RPCTypesConverter.AddressListConverter) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 AccountManager (org.aion.api.server.account.AccountManager)1 Request (org.aion.rpc.types.RPCTypes.Request)1 AddressListConverter (org.aion.rpc.types.RPCTypesConverter.AddressListConverter)1 AionAddress (org.aion.types.AionAddress)1 Test (org.junit.Test)1