|
28 | 28 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.Tracer; |
29 | 29 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace; |
30 | 30 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTracer; |
| 31 | +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcErrorResponse; |
31 | 32 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse; |
32 | 33 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; |
| 34 | +import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; |
33 | 35 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.OpCodeLoggerTracerResult; |
34 | 36 | import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.StructLog; |
35 | 37 | import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; |
@@ -181,48 +183,16 @@ public void shouldTraceTheTransactionUsingTheTransactionTracer() { |
181 | 183 |
|
182 | 184 | @Test |
183 | 185 | public void shouldNotTraceTheTransactionIfNotFound() { |
184 | | - final Map<String, Boolean> map = new HashMap<>(); |
185 | | - map.put("disableStorage", true); |
186 | | - final Object[] params = new Object[] {transactionHash, map}; |
| 186 | + final Object[] params = new Object[] {transactionHash}; |
187 | 187 | final JsonRpcRequestContext request = |
188 | 188 | new JsonRpcRequestContext(new JsonRpcRequest("2.0", "debug_traceTransaction", params)); |
189 | | - final TransactionProcessingResult result = mock(TransactionProcessingResult.class); |
190 | 189 |
|
191 | | - final TraceFrame traceFrame = |
192 | | - TraceFrame.builder() |
193 | | - .setPc(12) |
194 | | - .setOpcode("NONE") |
195 | | - .setOpcodeNumber(Integer.MAX_VALUE) |
196 | | - .setGasRemaining(45L) |
197 | | - .setGasCost(OptionalLong.of(56L)) |
198 | | - .setGasRefund(0L) |
199 | | - .setDepth(2) |
200 | | - .setRecipient(null) |
201 | | - .setValue(Wei.ZERO) |
202 | | - .setInputData(Bytes.EMPTY) |
203 | | - .setOutputData(Bytes.EMPTY) |
204 | | - .setWorldUpdater(null) |
205 | | - .setRevertReason(Optional.of(Bytes.fromHexString("0x1122334455667788"))) |
206 | | - .setStackItemsProduced(0) |
207 | | - .setVirtualOperation(false) |
208 | | - .build(); |
209 | | - final List<TraceFrame> traceFrames = Collections.singletonList(traceFrame); |
210 | | - final TransactionTrace transactionTrace = |
211 | | - new TransactionTrace(transaction, result, traceFrames); |
212 | | - when(transaction.getGasLimit()).thenReturn(100L); |
213 | | - when(result.getGasRemaining()).thenReturn(27L); |
214 | | - when(result.getOutput()).thenReturn(Bytes.fromHexString("1234")); |
215 | | - when(blockchainQueries.headBlockNumber()).thenReturn(12L); |
216 | 190 | when(blockchainQueries.transactionByHash(transactionHash)).thenReturn(Optional.empty()); |
217 | | - when(transactionTracer.traceTransaction( |
218 | | - any(Tracer.TraceableState.class), |
219 | | - eq(blockHash), |
220 | | - eq(transactionHash), |
221 | | - any(DebugOperationTracer.class))) |
222 | | - .thenReturn(Optional.of(transactionTrace)); |
223 | | - final JsonRpcSuccessResponse response = |
224 | | - (JsonRpcSuccessResponse) debugTraceTransaction.response(request); |
225 | 191 |
|
226 | | - assertThat(response.getResult()).isNull(); |
| 192 | + final JsonRpcResponse response = debugTraceTransaction.response(request); |
| 193 | + assertThat(response).isInstanceOf(JsonRpcErrorResponse.class); |
| 194 | + final JsonRpcErrorResponse errorResponse = (JsonRpcErrorResponse) response; |
| 195 | + assertThat(errorResponse.getErrorType()) |
| 196 | + .isEqualByComparingTo(RpcErrorType.TRANSACTION_NOT_FOUND); |
227 | 197 | } |
228 | 198 | } |
0 commit comments