use of org.aion.rpc.types.RPCTypes.Request 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
}
use of org.aion.rpc.types.RPCTypes.Request in project aion by aionnetwork.
the class StakingRPCImplTest method testCallUnityFeatureBeforeFork.
@Test
public void testCallUnityFeatureBeforeFork() {
chainHolder = spy(new AionChainHolder(AionImpl.instForTest(), accountManager));
doReturn(false).when(chainHolder).isUnityForkEnabled();
doCallRealMethod().when(chainHolder).getSeed();
rpcMethods = new RPCMethods(chainHolder);
try {
// This call will throw because a unity feature is requested before
// The unity fork
execute(new Request(1, "getseed", VoidParamsConverter.encode(new VoidParams()), VersionType.Version2), RPCTypesConverter.ByteArrayConverter::decode);
fail();
} catch (UnsupportedUnityFeatureRPCException e) {
// pass
}
}
use of org.aion.rpc.types.RPCTypes.Request in project aion by aionnetwork.
the class OpsRPCImplTest method testOps_getTransaction.
@Test
public void testOps_getTransaction() {
Request request = new Request(idGenerator.generateID(), getTransactionMethod, TransactionHashParamsConverter.encode(new TransactionHashParams(transactionHash)), VersionType.Version2);
assertNotNull(execute(request, OpsTransactionConverter::decode));
}
use of org.aion.rpc.types.RPCTypes.Request in project aion by aionnetwork.
the class OpsRPCImplTest method testOps_getAccountState.
@Test
public void testOps_getAccountState() {
AionAddress aionAddress = new AionAddress(ByteUtil.hexStringToBytes("a07913c03686c9659c1b614d098fd1db380a52b71fd58526b53d8107f7b355d5"));
Request request = new Request(idGenerator.generateID(), getAccountStateMethod, AddressParamsConverter.encode(new AddressParams(aionAddress)), VersionType.Version2);
final RPCTypes.AccountState result = execute(request, AccountStateConverter::decode);
assertNotNull(result);
assertEquals(aionAddress, result.address);
assertEquals(BigInteger.TEN, result.balance);
assertEquals(BigInteger.TEN, result.nonce);
}
use of org.aion.rpc.types.RPCTypes.Request in project aion by aionnetwork.
the class OpsRPCImplTest method testOps_getBlockDetails.
@Test
public void testOps_getBlockDetails() {
assertNotNull(execute(new Request(idGenerator.generateID(), "ops_getBlockDetails", BlockSpecifierParamsConverter.encode(new BlockSpecifierParams(new BlockSpecifierUnion(1L))), VersionType.Version2), BlockDetailsConverter::decode));
assertNotNull(execute(new Request(idGenerator.generateID(), "ops_getBlockDetails", BlockSpecifierParamsConverter.encode(BlockSpecifierParamsConverter.decode("[latest]")), VersionType.Version2), BlockDetailsConverter::decode));
assertNotNull(execute(new Request(idGenerator.generateID(), "ops_getBlockDetails", BlockSpecifierParamsConverter.encode(BlockSpecifierParamsConverter.decode("{\"block\": \"" + ByteArray.wrap(emptyPowBlock.getHash()) + "\"}")), VersionType.Version2), BlockDetailsConverter::decode));
}
Aggregations