use of org.aion.rpc.types.RPCTypes.VoidParams in project aion by aionnetwork.
the class MiningRPCImplTest method getWorkTest.
@Test
public void getWorkTest() {
ChainHolder chainHolder = new AionChainHolder(AionImpl.instForTest(), accountManager);
rpcMethods = new RPCMethods(chainHolder);
final BlockTemplate blockTemplate = rpcMethods.getBlockTemplate();
assertNotNull(blockTemplate);
assertTrue(chainHolder.canSeal(blockTemplate.headerHash.toBytes()));
BlockTemplateConverter.encode(blockTemplate);
final Request request = buildRequest("getBlockTemplate", VoidParamsConverter.encode(new VoidParams()));
BlockTemplateConverter.encode(execute(request, BlockTemplateConverter::decode));
}
use of org.aion.rpc.types.RPCTypes.VoidParams in project aion by aionnetwork.
the class MiningRPCImplTest method getDifficulty.
@Test
public void getDifficulty() {
ChainHolder chainHolder = new AionChainHolder(AionImpl.instForTest(), accountManager);
rpcMethods = new RPCMethods(chainHolder);
final BigInteger difficulty = rpcMethods.getDifficulty();
assertNotNull(difficulty);
final Request request = buildRequest("getDifficulty", VoidParamsConverter.encode(new VoidParams()));
BigIntConverter.encode(execute(request, RPCTypesConverter.BigIntConverter::decode));
}
use of org.aion.rpc.types.RPCTypes.VoidParams in project aion by aionnetwork.
the class PersonalRPCImplTest method executePersonal_ecRecover.
@Test
public void executePersonal_ecRecover() {
ECKey ecKey = ECKeyFac.inst().create();
String helloMessage = "Hello World";
ByteArray helloByteMessage = ByteArray.wrap(helloMessage.getBytes());
// Create the signed message
ByteArray signedMessage = ByteArray.wrap(ecKey.sign(helloByteMessage.toBytes()).toBytes());
String pubKey = ByteUtil.toHexString(ecKey.getAddress());
// well formed request
Request request = new Request(idGenerator.generateID(), ecRecoverMethod, EcRecoverParamsConverter.encode(new EcRecoverParams(helloByteMessage, signedMessage)), VersionType.Version2);
assertEquals(pubKey, execute(request, AddressConverter::decode).toString());
// incorrect method name
request = new Request(idGenerator.generateID(), ecRecoverMethod + "y", EcRecoverParamsConverter.encode(new EcRecoverParams(helloByteMessage, signedMessage)), VersionType.Version2);
try {
execute(request, AddressConverter::decode);
fail();
} catch (MethodNotFoundRPCException e) {
}
// incorrect params
request = new Request(idGenerator.generateID(), ecRecoverMethod, ParamUnion.wrap(new VoidParams()).encode(), VersionType.Version2);
try {
execute(request, AddressConverter::decode);
fail();
} catch (InvalidParamsRPCException e) {
}
}
use of org.aion.rpc.types.RPCTypes.VoidParams 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
}
}
Aggregations