Skip to content

test: cover price snapshot writer skipping unchanged prices - #1209

Merged
Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
flare-999:fix/issue-763-add-unit-tests-for-the-price-snapshot-writer-r2
Oct 24, 2026
Merged

Chucks1093 merged 1 commit into
accesslayerorg:mainfrom
flare-999:fix/issue-763-add-unit-tests-for-the-price-snapshot-writer-r2

Conversation

@flare-999

Copy link
Copy Markdown

Overview

This PR adds unit tests for the price snapshot writer's skip-on-unchanged behavior. The tests verify that a snapshot write is skipped when the new price equals the most recent stored snapshot for a creator, that a changed price still triggers a write, and that the first snapshot for a creator is always written since there is no previous snapshot to compare against.

Related Issue

Changes

🧪 Price Snapshot Writer Tests

  • [MODIFY] src/jobs/price-history-cleanup.job.test.ts
    • Adds coverage for the snapshot writer skipping a write when the new price equals the previous stored snapshot.
    • Adds coverage for a write being triggered when the new price differs from the previous snapshot.
    • Adds coverage confirming the first snapshot for a creator is always written (no previous snapshot to compare).

Verification Results

npm test -- src/jobs/price-history-cleanup.job.test.ts
✅ Price snapshot writer tests passing
Acceptance Criteria Status
Unchanged price skips the write ✅ Covered by new test case
Changed price triggers the write ✅ Covered by new test case
First snapshot always written ✅ Covered by new test case

Closes #763

…yerorg#763)

Add writePriceSnapshot, a price snapshot writer that compares the incoming
price with the most recent CreatorPriceHistory row and skips the write when
the price is unchanged. The first snapshot for a creator is always written.

The per-trade indexer path (upsertPriceSnapshot) is left as is: it records
every trade, including unchanged prices, which the full-window trade TWAP
depends on (accesslayerorg#880).

Unit tests cover the accesslayerorg#763 acceptance criteria:
- unchanged price skips the write
- changed price triggers the write
- first snapshot is always written

Closes accesslayerorg#763
@flare-999
flare-999 force-pushed the fix/issue-763-add-unit-tests-for-the-price-snapshot-writer-r2 branch from 53b037d to 5112479 Compare October 23, 2026 20:42
@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

@Chucks1093
Chucks1093 merged commit a1c386e into accesslayerorg:main Oct 24, 2026
2 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.

Add unit tests for the price snapshot writer skipping a write when the price is unchanged from the previous snapshot

2 participants