Problem
PaymentsService and MaintenanceWorker contain critical business logic (invoice lifecycle, fee calculations, scheduled invoice polling) but have very low or zero test coverage:
src/services/payments-service.ts — 8% statement coverage
src/app/maintenance-worker.ts — 0% coverage
Proposed Solution
Add unit tests for both modules using existing patterns (Mocha + Chai + Sinon):
payments-service.spec.ts (~29 tests):
getPendingInvoices() — delegation and error propagation
getInvoiceFromPaymentsProcessor() — string vs Invoice input handling, verifyURL logic
createInvoice() — transaction lifecycle (begin/commit/rollback), field mapping
updateInvoice() / updateInvoiceStatus() — delegation to repository
confirmInvoice() — validation guards, SATS/BTC/MSATS unit conversions, admission fee schedule filtering with pubkey whitelists, user admission on threshold met, transaction rollback on error
sendInvoiceUpdateNotification() — event construction, MSATS->SATS conversion, error logging in pipeline
maintenance-worker.spec.ts (~17 tests):
- Signal handler registration
- Interval scheduling
- Skips processing when payments disabled
- Invoice polling loop with per-invoice error resilience
- Status change detection (PENDING -> COMPLETED)
amountRequested fallback for amountPaid via mergeDeepLeft
close(), onError(), onExit() behavior
Impact
Raises overall unit test coverage from ~50% to ~55% statements. Both files reach 100% statement/function coverage.
Problem
PaymentsServiceandMaintenanceWorkercontain critical business logic (invoice lifecycle, fee calculations, scheduled invoice polling) but have very low or zero test coverage:src/services/payments-service.ts— 8% statement coveragesrc/app/maintenance-worker.ts— 0% coverageProposed Solution
Add unit tests for both modules using existing patterns (Mocha + Chai + Sinon):
payments-service.spec.ts (~29 tests):
getPendingInvoices()— delegation and error propagationgetInvoiceFromPaymentsProcessor()— string vs Invoice input handling, verifyURL logiccreateInvoice()— transaction lifecycle (begin/commit/rollback), field mappingupdateInvoice()/updateInvoiceStatus()— delegation to repositoryconfirmInvoice()— validation guards, SATS/BTC/MSATS unit conversions, admission fee schedule filtering with pubkey whitelists, user admission on threshold met, transaction rollback on errorsendInvoiceUpdateNotification()— event construction, MSATS->SATS conversion, error logging in pipelinemaintenance-worker.spec.ts (~17 tests):
amountRequestedfallback foramountPaidviamergeDeepLeftclose(),onError(),onExit()behaviorImpact
Raises overall unit test coverage from ~50% to ~55% statements. Both files reach 100% statement/function coverage.