fix: isRegistrationFullyExpired helper#2348
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe ChangesRegistration expiration boundary logic and tests
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Adjusts ENSNode SDK registration-expiration boundary logic so “fully expired” aligns with strict post-grace semantics, and adds Vitest coverage to lock in the expected behavior.
Changes:
- Change
isRegistrationFullyExpiredto use a strictnow > expiry + gracePeriodcomparison. - Add a new
registration-expiration.test.tssuite coveringisRegistrationExpired,isRegistrationFullyExpired, andisRegistrationInGracePeriod, including boundary cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/ensnode-sdk/src/registrars/registration-expiration.ts | Tweaks fully-expired boundary condition to be strict after grace period. |
| packages/ensnode-sdk/src/registrars/registration-expiration.test.ts | Adds unit tests validating expiration/grace behavior and boundary conditions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // otherwise it is expired if now > expiry + grace | ||
| return now > info.expiry + (info.gracePeriod ?? 0n); |
isRegistrationInGracePeriod helperisRegistrationFullyExpired helper
| // otherwise it is expired if now >= expiry + grace | ||
| return now >= info.expiry + (info.gracePeriod ?? 0n); | ||
| // otherwise it is expired if now > expiry + grace | ||
| return now > info.expiry + (info.gracePeriod ?? 0n); |
There was a problem hiding this comment.
Boundary gap breaks expired-state invariant
After the fix, at exactly now == expiry + gracePeriod all three helpers are inconsistent: isRegistrationExpired returns true (because expiry <= now), but isRegistrationInGracePeriod returns false (its upper bound is strictly expiry + gracePeriod > now) and isRegistrationFullyExpired now also returns false (the new strict now > expiry + gracePeriod). A registration is therefore expired, not in grace period, and not fully expired simultaneously — a state that should be impossible.
The original >= made isRegistrationFullyExpired true at the boundary and kept the functions mutually exclusive and exhaustive. The correct complementary partition is: grace period = [expiry, expiry + gracePeriod), fully expired = [expiry + gracePeriod, ∞), which requires >= in isRegistrationFullyExpired, not >.
|
|
||
| it("returns false when expiry is null", () => { |
There was a problem hiding this comment.
Wrong expected value for boundary case
The test asserts that isRegistrationFullyExpired returns false when now == expiry + gracePeriod (1100n). That assertion is incorrect: a registration whose grace period has just concluded is fully expired at that exact timestamp, not in some intermediate state. Keeping expected: true here (matching the original >= semantics) would correctly document that the boundary is the first instant of full expiry, consistent with how isRegistrationInGracePeriod already uses a strict upper-bound > to exclude that same instant.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
Why
Testing
Notes for Reviewer (Optional)
Pre-Review Checklist (Blocking)