test: cover DispatchProcessor commit safety across recovery-step exceptions - #26961
Open
ruslanvelkov-beep wants to merge 1 commit into
Open
Conversation
…ptions on handle failure Signed-off-by: Ruslan Velkov <ruslan.velkov@limechain.tech>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #26961 +/- ##
=========================================
Coverage 70.50% 70.50%
Complexity 11692 11692
=========================================
Files 2586 2586
Lines 108484 108484
Branches 12146 12146
=========================================
Hits 76490 76490
Misses 28014 28014
Partials 3980 3980 🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: 8bbc9e7 Learn more about TestLens at testlens.app/docs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds regression-guard unit tests for
DispatchProcessorproving that a handle-time failure neverleaves committed state inconsistent with a non-SUCCESS receipt.
processDispatchrunstryHandle(...)(which catchesHandleException/ThrottleException/genericExceptionand rolls the stack back on failure), thenfinalizeAndSaveUsage/finalizeRecord, andfinally
commitFullStack()as an ordinary last statement (notry/finally). So on a handled failurethe commit publishes an empty stack, and if any recovery/pre-commit step itself throws, the exception
escapes
processDispatchand the commit is skipped entirely — a skipped commit writes nothing, never apartial write.
Tests added (no production code changed)
DispatchProcessorTest:failedDispatchCommitsTheRolledBackStackSoReceiptMatchesState— on a handled failure, asserts (inorder)
stack.rollbackFullStack()runs beforestack.commitFullStack(), so the non-SUCCESS receiptis paired with an empty committed stack.
noStateIsCommittedWhenAnyRecoveryStepThrows— a parameterized matrix injecting each of severalunchecked exception types (
RuntimeException,IllegalStateException,IllegalArgumentException,ArithmeticException,NullPointerException,ClassCastException) at each recovery/pre-commit step(
rollbackFullStack,resetRefundableFees,reverseAccumulatedNodeFees,finalizeAndSaveUsage,finalizeRecord); every combination propagates out ofprocessDispatchandcommitFullStack()isnever invoked. (The recovery path declares no checked exceptions, so these exhaust its surface.)
Related issue(s)
N/A