use of co.rsk.rpc.modules.RskJsonRpcRequest in project rskj by rsksmart.
the class JacksonBasedRpcSerializerTest method testStringId_then_convertSuccessfully.
@Test
public void testStringId_then_convertSuccessfully() throws IOException {
String messageStr = "{\"jsonrpc\": \"2.0\",\"method\": \"eth_subscribe\",\"params\": [\"newHeads\"],\"id\": \"string\"}";
RskJsonRpcRequest requestFromStringId = convertJson(messageStr);
Assert.assertEquals("string", requestFromStringId.getId());
}
use of co.rsk.rpc.modules.RskJsonRpcRequest in project rskj by rsksmart.
the class EthSubscribeRequestTest method deserializePendingTransactions.
@Test
public void deserializePendingTransactions() throws IOException {
String message = "{\"jsonrpc\":\"2.0\",\"id\":333,\"method\":\"eth_subscribe\",\"params\":[\"newPendingTransactions\"]}";
RskJsonRpcRequest request = serializer.deserializeRequest(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)));
validateParams(request, EthSubscribePendingTransactionsParams.class);
}
use of co.rsk.rpc.modules.RskJsonRpcRequest in project rskj by rsksmart.
the class EthSubscribeRequestTest method deserializeNewHeads.
@Test
public void deserializeNewHeads() throws IOException {
String message = "{\"jsonrpc\":\"2.0\",\"id\":333,\"method\":\"eth_subscribe\",\"params\":[\"newHeads\"]}";
RskJsonRpcRequest request = serializer.deserializeRequest(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)));
validateParams(request, EthSubscribeNewHeadsParams.class);
}
use of co.rsk.rpc.modules.RskJsonRpcRequest in project rskj by rsksmart.
the class EthSubscribeRequestTest method deserializeLogsParametersAsArrays.
@Test
public void deserializeLogsParametersAsArrays() throws IOException {
RskAddress logAddress = new RskAddress("0x3e1127bf1a673d378a8570f7a79cea4f10e20489");
Topic logTopic = new Topic("0x2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df");
String message = "{\"jsonrpc\":\"2.0\",\"id\":333,\"method\":\"eth_subscribe\",\"params\":[\"logs\", {\"address\":[\"" + logAddress.toJsonString() + "\"],\"topics\":[\"" + logTopic.toJsonString() + "\"]}]}";
RskJsonRpcRequest request = serializer.deserializeRequest(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)));
EthSubscribeLogsParams logsParams = validateParams(request, EthSubscribeLogsParams.class);
assertThat(logsParams.getAddresses(), is(arrayWithSize(1)));
assertThat(logsParams.getAddresses(), hasItemInArray(logAddress));
assertThat(logsParams.getTopics(), is(arrayWithSize(1)));
assertThat(logsParams.getTopics()[0], is(arrayWithSize(1)));
assertThat(logsParams.getTopics()[0], hasItemInArray(logTopic));
}
use of co.rsk.rpc.modules.RskJsonRpcRequest in project rskj by rsksmart.
the class EthSubscribeRequestTest method deserializeLogsSingleParameters.
@Test
public void deserializeLogsSingleParameters() throws IOException {
RskAddress logAddress = new RskAddress("0x3e1127bf1a673d378a8570f7a79cea4f10e20489");
Topic logTopic = new Topic("0x2809c7e17bf978fbc7194c0a694b638c4215e9140cacc6c38ca36010b45697df");
String message = "{\"jsonrpc\":\"2.0\",\"id\":333,\"method\":\"eth_subscribe\",\"params\":[\"logs\", {\"address\":\"" + logAddress.toJsonString() + "\",\"topics\":\"" + logTopic.toJsonString() + "\"}]}";
RskJsonRpcRequest request = serializer.deserializeRequest(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)));
EthSubscribeLogsParams logsParams = validateParams(request, EthSubscribeLogsParams.class);
assertThat(logsParams.getAddresses(), is(arrayWithSize(1)));
assertThat(logsParams.getAddresses(), hasItemInArray(logAddress));
assertThat(logsParams.getTopics(), is(arrayWithSize(1)));
assertThat(logsParams.getTopics()[0], is(arrayWithSize(1)));
assertThat(logsParams.getTopics()[0], hasItemInArray(logTopic));
}
Aggregations