Skip to content

[Testing] Add unit tests for scoreDecayService inactivity decay logic #955

@Akpolo

Description

@Akpolo

https://t.me/+DOylgFv1jyJlNzM0

Why this matters

scoreDecayService.ts (with cron/scoreDecayJob.ts) decays credit scores for inactive borrowers (#535). The job wrapper has a test (cron/__tests__/scoreDecayJob.test.ts) but the service that computes WHICH users decay and by HOW MUCH is untested. Credit-score mutation is financially sensitive — an off-by-one in the inactivity window or decay amount silently penalizes active users or never decays inactive ones.

Acceptance criteria

  • Add scoreDecayService tests covering: user inactive past the threshold decays by the configured amount, active user does not decay, decay floored at the minimum score, and batch processing across multiple users
  • Assert score-floor and idempotency (running twice in the same window does not double-decay)
  • Mock the DB/contract layer consistently with existing service tests

Files to touch

  • backend/src/services/__tests__/scoreDecayService.test.ts (new)

Out of scope

  • Changing decay parameters or schedule
  • Contract-side score logic

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendIssues related to backend developmenttestingAdding or fixing tests

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions