Skip to content

feat(backend): add ledger sequence difference calculator module (#373) - #471

Open
jdjioe5-cpu wants to merge 1 commit into
Kitewell-lab:mainfrom
jdjioe5-cpu:feat/issue-373-ledger-sequence-diff
Open

jdjioe5-cpu wants to merge 1 commit into
Kitewell-lab:mainfrom
jdjioe5-cpu:feat/issue-373-ledger-sequence-diff

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Summary

Implements the ledger sequence difference calculator in backend/src/ledgerSequenceDiff.js to compute non-negative ledger count differences between two ledger sequence numbers per #373.

Changes

  • Add backend/src/ledgerSequenceDiff.js exporting calculateLedgerDiff (and ledgerSequenceDiff alias)
  • Validate non-negative integer bounds and clarify which sequence argument is newer ("first", "second", or null when identical)
  • Export constants in backend/src/ledgerSequenceDiffConstants.js (LEDGER_SEQUENCE_ARGUMENT, LEDGER_SEQUENCE_SIGN, LEDGER_SEQUENCE_ERROR)
  • Add 9 single-behavior node:test test files in backend/src/:
    • ledgerSequenceDiff-happy.test.js (happy path)
    • ledgerSequenceDiff-first-newer.test.js (first sequence newer)
    • ledgerSequenceDiff-second-newer.test.js (second sequence newer)
    • ledgerSequenceDiff-equal.test.js (identical sequence numbers)
    • ledgerSequenceDiff-boundary.test.js (boundary difference and safe integer handling)
    • ledgerSequenceDiff-options-object.test.js (options object interface)
    • ledgerSequenceDiff-invalid-negative.test.js (negative number rejection)
    • ledgerSequenceDiff-invalid-non-integer.test.js (non-integer rejection)
    • ledgerSequenceDiff-invalid-missing.test.js (missing input rejection)
    • ledgerSequenceDiff-constants.test.js (constant immutability verification)
  • Add documentation in docs/features/ledgerSequenceDiff.md
  • No existing files modified

Verification

  • npm test run from backend/ passes 396/396 tests clean

Closes #373

- Implement backend/src/ledgerSequenceDiff.js to compute non-negative ledger count differences
- Validate non-negative integer bounds and clarify which sequence argument is newer
- Export constants LEDGER_SEQUENCE_ARGUMENT, LEDGER_SEQUENCE_SIGN, and LEDGER_SEQUENCE_ERROR
- Add 9 single-behavior node:test test files covering directional checks, equality, boundary, BigInt safety, options objects, constants, and invalid inputs
- Add feature documentation under docs/features/ledgerSequenceDiff.md

Closes Kitewell-lab#373
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.

New backend module: backend/src/ledgerSequenceDiff.js — Ledger sequence difference calculator

1 participant