From 579ad3c33c064d282fe07c43c460935cd12d68bf Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Wed, 10 Apr 2024 10:59:24 +0100 Subject: [PATCH] fix(test): releases response size limit ctx after test --- .../java/co/rsk/rpc/netty/JsonRpcCustomServerTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rskj-core/src/test/java/co/rsk/rpc/netty/JsonRpcCustomServerTest.java b/rskj-core/src/test/java/co/rsk/rpc/netty/JsonRpcCustomServerTest.java index f756b937be5..8d4d20c9655 100644 --- a/rskj-core/src/test/java/co/rsk/rpc/netty/JsonRpcCustomServerTest.java +++ b/rskj-core/src/test/java/co/rsk/rpc/netty/JsonRpcCustomServerTest.java @@ -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 @@ -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());