Skip to content

test: add callback controller specs#494

Merged
cameri merged 5 commits intocameri:mainfrom
Anshumancanrock:test/payment-callback-controllers-unit-tests
Apr 18, 2026
Merged

test: add callback controller specs#494
cameri merged 5 commits intocameri:mainfrom
Anshumancanrock:test/payment-callback-controllers-unit-tests

Conversation

@Anshumancanrock
Copy link
Copy Markdown
Collaborator

Description

Added unit tests for all payment callback controllers under test/unit/controllers/callbacks/.

Covered:

  • valid and invalid payloads per provider
  • authentication/signature verification branches
  • processor/authorization guard branches
  • invoice transition and error paths with dependencies stubbed

Related Issue

Closes #490

Motivation and Context

Callback controllers had low coverage and untested conditional logic. This PR improves confidence in callback handling and reduces regression risk.

How Has This Been Tested?

  • npm run test:unit -- 'test/unit/controllers/callbacks/**/*.spec.ts'
  • npm run cover:unit

Result:

  • 583 passing

Screenshots (if appropriate):

N/A

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • All new and existing tests passed.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds unit test coverage for the payment callback controllers to exercise previously untested validation/auth and invoice-transition branches, improving confidence and reducing regression risk in callback handling.

Changes:

  • Added unit specs for LNbits, Nodeless, OpenNode, and Zebedee callback controllers.
  • Covered malformed payload handling, auth/signature/guard branches, invoice state transitions, and error propagation paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
test/unit/controllers/callbacks/lnbits-callback-controller.spec.ts Adds LNbits callback controller unit tests (HMAC query auth, body validation, invoice transitions, error paths).
test/unit/controllers/callbacks/nodeless-callback-controller.spec.ts Adds Nodeless callback controller unit tests (signature verification, processor guard, transitions, error paths).
test/unit/controllers/callbacks/opennode-callback-controller.spec.ts Adds OpenNode callback controller unit tests (payload validation, transitions, error paths).
test/unit/controllers/callbacks/zebedee-callback-controller.spec.ts Adds Zebedee callback controller unit tests (IP whitelist + processor guard, payload validation, transitions, error paths).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +66 to +67
const makeValidQuery = (expiry = Date.now() + 60_000) => {
const expiryString = String(expiry)
}
}

const makeValidQuery = (expiry = Date.now() + 60_000) => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use Sinon fake timers if we are using Date.now() to avoid creating flaky tests

@Anshumancanrock Anshumancanrock force-pushed the test/payment-callback-controllers-unit-tests branch from 969ad58 to 1a1adb3 Compare April 18, 2026 16:34
@Anshumancanrock
Copy link
Copy Markdown
Collaborator Author

@cameri Done! Added Sinon fake timers and a fixed expiry date to prevent test flakiness.

@Anshumancanrock Anshumancanrock requested a review from cameri April 18, 2026 16:38
@cameri cameri self-assigned this Apr 18, 2026
@cameri cameri merged commit 26bcdd5 into cameri:main Apr 18, 2026
9 checks passed
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.

test: add unit tests for payment callback controllers

3 participants