Skip to content

test: fix expired GovObject proposal fixtures#316

Merged
PastaPastaPasta merged 1 commit into
dashpay:masterfrom
thepastaclaw:fix-govobject-date-fixtures
May 26, 2026
Merged

test: fix expired GovObject proposal fixtures#316
PastaPastaPasta merged 1 commit into
dashpay:masterfrom
thepastaclaw:fix-govobject-date-fixtures

Conversation

@thepastaclaw

@thepastaclaw thepastaclaw commented May 26, 2026

Copy link
Copy Markdown

Fix expired GovObject proposal fixtures

Summary

  • Freeze the affected GovObject/Proposal test suites' clock at
    2024-01-01T00:00:00Z.
  • Keep the historical 2025-10-10 proposal fixture valid without changing
    serialized fixture hex.
  • Avoid production-code changes; this only restores deterministic tests for the
    existing fixture data.

Validation

  • npm run test:node -- --grep 'GovObject|Proposal' -> 50 passing
  • npm run test:node -> 3509 passing, 17 pending
  • npm test was also attempted locally, but the browser/Karma phase cannot
    launch Firefox in this environment:
    No binary for Firefox browser on your platform. The node test phase is
    covered above.

Review

  • Pre-PR code review gate: ship

Summary by CodeRabbit

  • Tests
    • Enhanced test suite timing controls to improve reliability of time-dependent test scenarios.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a815a2e-ecbb-42ff-b8d2-37736d182448

📥 Commits

Reviewing files that changed from the base of the PR and between c3c3fe5 and 72e0e1d.

📒 Files selected for processing (2)
  • test/govobject/govobject.js
  • test/govobject/types/proposal.js

📝 Walkthrough

Walkthrough

Two test suites—GovObject and Proposal—now set up and tear down Sinon fake timers at a fixed UTC timestamp (2024-01-01T00:00:00Z) before and after test execution to ensure deterministic time-dependent behavior during testing.

Changes

Sinon fake timer setup in test suites

Layer / File(s) Summary
Sinon fake timer setup in Proposal test suite
test/govobject/types/proposal.js
Introduces a clock variable and before/after hooks to install fake timers at a fixed UTC timestamp and restore real timers after tests complete.
Sinon fake timer setup in GovObject test suite
test/govobject/govobject.js
Adds before/after hooks within the GovObject - FromObject suite to initialize and restore fake timers with a matching fixed UTC timestamp.

🎯 1 (Trivial) | ⏱️ ~3 minutes

🐰 Time stands still in tests today,
Clocks are frozen in their way,
No more flaky moments passed,
Fixed timestamps hold steadfast! ⏰✨

🚥 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 clearly and specifically describes the main change: fixing expired GovObject proposal test fixtures by freezing the clock.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@thepastaclaw

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@PastaPastaPasta PastaPastaPasta marked this pull request as ready for review May 26, 2026 17:19
@PastaPastaPasta PastaPastaPasta requested a review from shumkov May 26, 2026 17:20

@PastaPastaPasta PastaPastaPasta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me.

@PastaPastaPasta PastaPastaPasta merged commit a1da488 into dashpay:master May 26, 2026
3 checks passed

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Test-only PR freezes the wall clock at 2024-01-01 inside the two GovObject/Proposal describes whose fixtures embed an end_epoch of 2025-10-10, so Proposal#getSerializationError's end_epoch < now check no longer rejects them. Sinon is already required in both files, the freeze date sits inside the [2015-10-10, 2025-10-10] window, and the explicit expired-date negative tests use pre-2024 dates so they still trigger expiry. Both reviewing agents reported no defects; verified against the diff.

Out-of-scope follow-up suggestions (2)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Proposal validation hard-codes wall-clock checklib/govobject/types/proposal.js validates end_epoch >= now against real wall time. That is the underlying reason fixtures must be patched in tests as time marches on, and downstream consumers can see previously-valid GovObjects become invalid solely due to clock drift. Not introduced or affected by this PR.
    • Follow-up: Open a separate issue to discuss decoupling Proposal serialization validation from wall-clock time (e.g., optional clock parameter, or separating parse-vs-submit checks).
  • Other GovObject test files may share the same time-bomb risk — This PR patches two known suites. Any future test that constructs Proposals with hard-coded end_epoch dates will hit the same expiry issue. A shared mocha root-hook helper would prevent recurrence without touching production code.
    • Follow-up: Author-requested follow-up PR to introduce a shared freezeProposalClock() helper (or a mocha root before/after) for any test that serializes Proposals.

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.

3 participants