Skip to content

test(staleness): pin exact-timeout and just-stale LTS boundary tests#190

Open
thedavidmeister wants to merge 2 commits into
mainfrom
2026-06-30-issue-55-staleness-boundary
Open

test(staleness): pin exact-timeout and just-stale LTS boundary tests#190
thedavidmeister wants to merge 2 commits into
mainfrom
2026-06-30-issue-55-staleness-boundary

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #55

Problem

testFtsoV2LTSGetFeedStale exercised only a single stale point (warp +3601 over a 3600 timeout). The off-by-one boundary of the block.timestamp > timestamp + timeout predicate was unverified: a regression flipping > to >= (or an off-by-one in the timeout arithmetic) would not be caught.

timeout == 0 (every block is stale once the feed is updated) was also unexercised.

Fix

Adds four boundary tests to LibFtsoV2LTSTest:

Test condition expected
testFtsoV2LTSGetFeedExactTimeoutNotStale block.timestamp == feedTimestamp + timeout succeeds (strict > so equal is not stale)
testFtsoV2LTSGetFeedJustStale block.timestamp == feedTimestamp + timeout + 1 reverts StalePrice
testFtsoV2LTSGetFeedTimeoutZeroStale timeout == 0, block.timestamp = feedTimestamp + 1 reverts StalePrice
testFtsoV2LTSGetFeedTimeoutZeroExactNotStale timeout == 0, block.timestamp == feedTimestamp succeeds

All four tests use vm.warp(absolute) anchored to the hardcoded feed timestamp 1729795768 (the ETH_USD feed value at BLOCK_NUMBER = 31843105, already used in the existing stale test). All 7 LibFtsoV2LTSTest tests pass.

Summary by CodeRabbit

  • Tests
    • Added coverage for feed freshness edge cases, including exact timeout boundaries and zero-timeout behavior.
    • Improved validation that stale feed values correctly revert while fresh values remain usable.

…feed

Closes #55

Adds four staleness-boundary tests to LibFtsoV2LTSTest:
- testFtsoV2LTSGetFeedExactTimeoutNotStale: block.timestamp == feedTimestamp +
  timeout must succeed (staleness check is strict >)
- testFtsoV2LTSGetFeedJustStale: block.timestamp == feedTimestamp + timeout + 1
  must revert with StalePrice
- testFtsoV2LTSGetFeedTimeoutZeroStale: timeout == 0, any timestamp after
  feedTimestamp is stale
- testFtsoV2LTSGetFeedTimeoutZeroExactNotStale: timeout == 0 at exactly
  feedTimestamp is not stale (0 > 0 is false)

A regression flipping > to >= (or off-by-one in the timeout arithmetic)
would be caught by the exact-boundary tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ad25e9db-29d3-45f3-bc33-6e75e0d1b164

📥 Commits

Reviewing files that changed from the base of the PR and between cb20d03 and 622443d.

📒 Files selected for processing (1)
  • test/src/lib/lts/LibFtsoV2LTS.t.sol

Walkthrough

Four new test functions are added to LibFtsoV2LTSTest covering boundary behavior of the FTSO V2 LTS staleness predicate (block.timestamp > feedTimestamp + timeout): exact boundary (not stale), one second past boundary (stale), timeout==0 with later timestamp (stale), and timeout==0 at exact feed timestamp (not stale).

Changes

FTSO V2 LTS staleness boundary tests

Layer / File(s) Summary
Staleness boundary and timeout==0 tests
test/src/lib/lts/LibFtsoV2LTS.t.sol
Adds four tests using vm.warp and vm.expectRevert to verify both sides of the block.timestamp > feedTimestamp + timeout boundary and both sides of the timeout==0 edge case.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately highlights the staleness boundary test additions.
Linked Issues check ✅ Passed The PR covers the requested exact-timeout, one-second-over, fresh feed, and zero-timeout boundary cases pinned to the target fork.
Out of Scope Changes check ✅ Passed The changes stay focused on the linked staleness-boundary tests in the specified LTS test file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-30-issue-55-staleness-boundary

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Test failed due to RPC rate limit exhausted (call rate limit exhausted, retry in 10s).

Co-Authored-By: Claude <noreply@anthropic.com>
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.

[F08] [MEDIUM] No boundary coverage for the staleness condition (exact timeout, one-second-over, fresh)

1 participant