Skip to content

fix(core): dedupe proof watcher finalization checks#180

Open
Egge21M wants to merge 2 commits into
masterfrom
fix/proof-state-watchers
Open

fix(core): dedupe proof watcher finalization checks#180
Egge21M wants to merge 2 commits into
masterfrom
fix/proof-state-watchers

Conversation

@Egge21M

@Egge21M Egge21M commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Description

This pull request fixes redundant proof watcher send finalization checks.

Problem

Spent proof handling could trigger repeated send finalization work for the same operation. A subscription-driven spent notification already emitted a proof state event that finalized the send, and batched spent events could also repeat the operation-level check once per proof from the same send operation.

Summary

  • Remove the direct subscription callback finalization path and let proof state events own send finalization.
  • Deduplicate candidate send operation IDs within a single spent-proof event before running the all-spent finalization check.
  • Add focused watcher tests for subscription notifications, same-operation batched events, and multi-operation batched events.
  • Add/update the core patch changeset.

Verification

  • bun run --filter='@cashu/coco-core' test -- test/unit/ProofStateWatcherService.test.ts
  • bun run --filter='@cashu/coco-core' test -- test/unit/SendOperationService.test.ts
  • bun run --filter='@cashu/coco-core' typecheck
  • git diff --check

Changeset

  • .changeset/single-proof-finalization.md

@changeset-bot

changeset-bot Bot commented May 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b6093f4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@cashu/coco-core Patch
@cashu/coco-adapter-tests Patch
@cashu/coco-expo-sqlite Patch
@cashu/coco-indexeddb Patch
@cashu/coco-react Patch
@cashu/coco-sqlite-bun Patch
@cashu/coco-sqlite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.94%. Comparing base (c321b30) to head (b6093f4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #180      +/-   ##
==========================================
+ Coverage   84.29%   84.94%   +0.65%     
==========================================
  Files         115      115              
  Lines       13928    13915      -13     
==========================================
+ Hits        11740    11820      +80     
+ Misses       2188     2095      -93     
Flag Coverage Δ
core-integration 54.01% <ø> (ø)
core-unit 88.28% <100.00%> (+0.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 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.

@Egge21M Egge21M marked this pull request as ready for review May 20, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant