Skip to content

Commit

Permalink
fix(test): releases response size limit ctx after test
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajpiar committed Apr 10, 2024
1 parent ab724d8 commit 5f582b7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ void testHandleJsonNodeRequest_WithResponseLimit() throws Exception {
JsonNode request = objectMapper.readTree(FIRST_METHOD_REQUEST);
Web3Test handler = mock(Web3Test.class);
//expected response would be {"jsonrpc":"2.0","id":1,"result":"test_method_response"} with 56 bytes
ResponseSizeLimitContext.createResponseSizeContext(55);
ResponseSizeLimitContext limitContext = ResponseSizeLimitContext.createResponseSizeContext(55);
jsonRpcCustomServer = new JsonRpcCustomServer(handler, Web3Test.class, modules, objectMapper);

when(handler.test_first(anyString())).thenReturn(response);

assertThrows(JsonRpcResponseLimitError.class, () -> jsonRpcCustomServer.handleJsonNodeRequest(request));
limitContext.close();
}

@Test
Expand Down Expand Up @@ -247,7 +248,9 @@ void failedEthCall_givenRskErrorResolver_shouldThrowWithData() throws JsonProces
FakeWeb3ForEthCall web3ForEthCall = mock(FakeWeb3ForEthCall.class);
ProgramRevert fakeProgramRevert = new ProgramRevert("deposit too big", revertBytes);
RskJsonRpcRequestException exception = RskJsonRpcRequestException.transactionRevertedExecutionError(fakeProgramRevert);
when(web3ForEthCall.eth_call(any(), any())).thenThrow(exception);
when(web3ForEthCall.eth_call(any(), any())).then(invocation -> {
throw exception;
});
jsonRpcCustomServer = new JsonRpcCustomServer(web3ForEthCall, FakeWeb3ForEthCall.class, modules, objectMapper);
jsonRpcCustomServer.setErrorResolver(new RskErrorResolver());

Expand Down

0 comments on commit 5f582b7

Please sign in to comment.