Skip to content

test: cover DispatchProcessor commit safety across recovery-step exceptions - #26961

Open
ruslanvelkov-beep wants to merge 1 commit into
hiero-ledger:mainfrom
ruslanvelkov-beep:test/dispatch-processor-rollback-commit-safety
Open

test: cover DispatchProcessor commit safety across recovery-step exceptions#26961
ruslanvelkov-beep wants to merge 1 commit into
hiero-ledger:mainfrom
ruslanvelkov-beep:test/dispatch-processor-rollback-commit-safety

Conversation

@ruslanvelkov-beep

Copy link
Copy Markdown
Contributor

Description

Adds regression-guard unit tests for DispatchProcessor proving that a handle-time failure never
leaves committed state inconsistent with a non-SUCCESS receipt.

processDispatch runs tryHandle(...) (which catches HandleException/ThrottleException/generic
Exception and rolls the stack back on failure), then finalizeAndSaveUsage/finalizeRecord, and
finally commitFullStack() as an ordinary last statement (no try/finally). So on a handled failure
the commit publishes an empty stack, and if any recovery/pre-commit step itself throws, the exception
escapes processDispatch and the commit is skipped entirely — a skipped commit writes nothing, never a
partial write.

Tests added (no production code changed)

DispatchProcessorTest:

  • failedDispatchCommitsTheRolledBackStackSoReceiptMatchesState — on a handled failure, asserts (in
    order) stack.rollbackFullStack() runs before stack.commitFullStack(), so the non-SUCCESS receipt
    is paired with an empty committed stack.
  • noStateIsCommittedWhenAnyRecoveryStepThrows — a parameterized matrix injecting each of several
    unchecked exception types (RuntimeException, IllegalStateException, IllegalArgumentException,
    ArithmeticException, NullPointerException, ClassCastException) at each recovery/pre-commit step
    (rollbackFullStack, resetRefundableFees, reverseAccumulatedNodeFees, finalizeAndSaveUsage,
    finalizeRecord); every combination propagates out of processDispatch and commitFullStack() is
    never invoked. (The recovery path declares no checked exceptions, so these exhaust its surface.)

Related issue(s)

N/A

…ptions on handle failure

Signed-off-by: Ruslan Velkov <ruslan.velkov@limechain.tech>
@ruslanvelkov-beep
ruslanvelkov-beep requested a review from a team as a code owner August 25, 2026 12:24
@ruslanvelkov-beep ruslanvelkov-beep self-assigned this Aug 25, 2026
@lfdt-bot

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@            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           

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Aug 25, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 8bbc9e7
▶️ Tests: 11082 executed
⚪️ Checks: 37/37 completed


Learn more about TestLens at testlens.app/docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants