Search in sources :

Example 1 with UnlockAccountParams

use of org.aion.rpc.types.RPCTypes.UnlockAccountParams in project aion by aionnetwork.

the class PersonalRPCImplTest method testPersonal_unlockAccount.

@Test
public void testPersonal_unlockAccount() {
    AionAddress address = new AionAddress(ByteUtil.hexStringToBytes("a07913c03686c9659c1b614d098fd1db380a52b71fd58526b53d8107f7b355d5"));
    String password0 = "password";
    String password1 = "password1";
    int timeout0 = 300;
    Integer timeout1 = null;
    UnlockAccountParams params0 = new UnlockAccountParams(address, password0, timeout0);
    UnlockAccountParams params1 = new UnlockAccountParams(address, password1, timeout1);
    // check that the rpc library creates a default value for the duration
    assertNotNull(params1.duration);
    doReturn(false).when(chainHolder).unlockAccount(eq(address), eq(password0), anyInt());
    doReturn(true).when(chainHolder).unlockAccount(eq(address), eq(password1), anyInt());
    assertFalse(execute(new Request(idGenerator.generateID(), unlockAccountMethod, UnlockAccountParamsConverter.encode(params0), VersionType.Version2), BoolConverter::decode));
    assertTrue(execute(new Request(idGenerator.generateID(), unlockAccountMethod, UnlockAccountParamsConverter.encode(params1), VersionType.Version2), BoolConverter::decode));
}
Also used : AionAddress(org.aion.types.AionAddress) Request(org.aion.rpc.types.RPCTypes.Request) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) UnlockAccountParams(org.aion.rpc.types.RPCTypes.UnlockAccountParams) Test(org.junit.Test)

Aggregations

Request (org.aion.rpc.types.RPCTypes.Request)1 UnlockAccountParams (org.aion.rpc.types.RPCTypes.UnlockAccountParams)1 AionAddress (org.aion.types.AionAddress)1 Test (org.junit.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1