|
17 | 17 | package com.hedera.node.app.workflows.ingest;
|
18 | 18 |
|
19 | 19 | import static com.hedera.hapi.node.base.ResponseCodeEnum.BUSY;
|
| 20 | +import static com.hedera.hapi.node.base.ResponseCodeEnum.FAIL_INVALID; |
20 | 21 | import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_SIGNATURE;
|
21 | 22 | import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_TRANSACTION;
|
22 | 23 | import static com.hedera.hapi.node.base.ResponseCodeEnum.INVALID_TRANSACTION_BODY;
|
@@ -250,14 +251,18 @@ void onsetFailsWithPreCheckException(ResponseCodeEnum failureReason) throws PreC
|
250 | 251 |
|
251 | 252 | @Test
|
252 | 253 | @DisplayName("If some random exception is thrown from TransactionChecker, the exception is bubbled up")
|
253 |
| - void randomException() throws PreCheckException { |
| 254 | + void randomException() throws PreCheckException, ParseException { |
254 | 255 | // Given a WorkflowOnset that will throw a RuntimeException
|
255 | 256 | when(transactionChecker.parse(any())).thenThrow(new RuntimeException("parseAndCheck exception"));
|
256 | 257 |
|
257 |
| - // When the transaction is submitted, then the exception is bubbled up |
258 |
| - assertThatThrownBy(() -> workflow.submitTransaction(requestBuffer, responseBuffer)) |
259 |
| - .isInstanceOf(RuntimeException.class) |
260 |
| - .hasMessageContaining("parseAndCheck exception"); |
| 258 | + // When the transaction is submitted |
| 259 | + workflow.submitTransaction(requestBuffer, responseBuffer); |
| 260 | + |
| 261 | + // Then the response will indicate the platform rejected the transaction |
| 262 | + final TransactionResponse response = parseResponse(responseBuffer); |
| 263 | + assertThat(response.nodeTransactionPrecheckCode()).isEqualTo(FAIL_INVALID); |
| 264 | + // And the cost will be zero |
| 265 | + assertThat(response.cost()).isZero(); |
261 | 266 | // And the transaction is not submitted to the platform
|
262 | 267 | verify(submissionManager, never()).submit(any(), any());
|
263 | 268 | }
|
@@ -296,15 +301,19 @@ void testIngestChecksFail(ResponseCodeEnum failureReason) throws PreCheckExcepti
|
296 | 301 |
|
297 | 302 | @Test
|
298 | 303 | @DisplayName("If some random exception is thrown from IngestChecker, the exception is bubbled up")
|
299 |
| - void randomException() throws PreCheckException { |
| 304 | + void randomException() throws PreCheckException, ParseException { |
300 | 305 | // Given a ThrottleAccumulator that will throw a RuntimeException
|
301 | 306 | when(ingestChecker.runAllChecks(state, transaction, configuration))
|
302 | 307 | .thenThrow(new RuntimeException("runAllChecks exception"));
|
303 | 308 |
|
304 |
| - // When the transaction is submitted, then the exception is bubbled up |
305 |
| - assertThatThrownBy(() -> workflow.submitTransaction(requestBuffer, responseBuffer)) |
306 |
| - .isInstanceOf(RuntimeException.class) |
307 |
| - .hasMessageContaining("runAllChecks exception"); |
| 309 | + // When the transaction is submitted |
| 310 | + workflow.submitTransaction(requestBuffer, responseBuffer); |
| 311 | + |
| 312 | + // Then the response will indicate the platform rejected the transaction |
| 313 | + final TransactionResponse response = parseResponse(responseBuffer); |
| 314 | + assertThat(response.nodeTransactionPrecheckCode()).isEqualTo(FAIL_INVALID); |
| 315 | + // And the cost will be zero |
| 316 | + assertThat(response.cost()).isZero(); |
308 | 317 | // And the transaction is not submitted to the platform
|
309 | 318 | verify(submissionManager, never()).submit(any(), any());
|
310 | 319 | }
|
@@ -334,16 +343,20 @@ void testSubmitFails() throws PreCheckException, ParseException {
|
334 | 343 |
|
335 | 344 | @Test
|
336 | 345 | @DisplayName("If some random exception is thrown from submitting to the platform, the exception is bubbled up")
|
337 |
| - void randomException() throws PreCheckException { |
| 346 | + void randomException() throws PreCheckException, ParseException { |
338 | 347 | // Given a SubmissionManager that will throw a RuntimeException from submit
|
339 | 348 | doThrow(new RuntimeException("submit exception"))
|
340 | 349 | .when(submissionManager)
|
341 | 350 | .submit(any(), any());
|
342 | 351 |
|
343 |
| - // When the transaction is submitted, then the exception is bubbled up |
344 |
| - assertThatThrownBy(() -> workflow.submitTransaction(requestBuffer, responseBuffer)) |
345 |
| - .isInstanceOf(RuntimeException.class) |
346 |
| - .hasMessageContaining("submit exception"); |
| 352 | + // When the transaction is submitted |
| 353 | + workflow.submitTransaction(requestBuffer, responseBuffer); |
| 354 | + |
| 355 | + // Then the response will indicate the platform rejected the transaction |
| 356 | + final TransactionResponse response = parseResponse(responseBuffer); |
| 357 | + assertThat(response.nodeTransactionPrecheckCode()).isEqualTo(FAIL_INVALID); |
| 358 | + // And the cost will be zero |
| 359 | + assertThat(response.cost()).isZero(); |
347 | 360 | }
|
348 | 361 | }
|
349 | 362 |
|
|
0 commit comments