Skip to content

test(mcp): pin the auth-tool expiresAt to the effective wait timeout - #2616

Closed
xpzouying wants to merge 1 commit into
MoonshotAI:mainfrom
xpzouying:test/mcp-auth-expiresat-precision
Closed

test(mcp): pin the auth-tool expiresAt to the effective wait timeout#2616
xpzouying wants to merge 1 commit into
MoonshotAI:mainfrom
xpzouying:test/mcp-auth-expiresat-precision

Conversation

@xpzouying

Copy link
Copy Markdown
Contributor

Related Issue

Follow-up to #2609 — tightens the tests it added; no separate issue.

Problem

The v1/v2 auth-tool suites construct the tool with a timeoutMs: 100 override, but the expiresAt assertions added in #2609 only bound the value by the 15-minute default — they pass even if the implementation ignored the override. Worse, the lower bound compares against Date.now() taken after the run completes, so the assertion becomes flaky the moment the test body takes longer than the 100ms override.

What changed

Test-only. Both suites capture before = Date.now() ahead of the run and assert expiresAt ∈ [before + 100, Date.now() + 100] — pinning the deadline to emit time + the effective wait timeout exactly, with bounds that hold regardless of how long the test body takes.

No changeset: tests only.

Verification

Both auth-tool suites pass (5 tests each); oxlint clean.

Both suites construct the tool with a 100ms timeout override, but the
assertions only bounded expiresAt by the 15-minute default — and the
lower bound compared against Date.now() taken after the run, which
turns into a flake the moment the test body outlives the override.
Bound by the window around the run instead: expiresAt must equal
emit time + the effective timeout.
@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2d21c0f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@xpzouying

Copy link
Copy Markdown
Contributor Author

Closing — this is a test-only precision tweak; folding it into a future substantive PR instead of spending review bandwidth on a standalone one.

@xpzouying xpzouying closed this Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2d21c0f95b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +73 to +77
// The deadline is absolute (emit time + the effective wait timeout — the
// 100ms override here, not the 15-minute default), so hosts render from
// data instead of mirroring the engine constant. Bounding by the time
// window around the run keeps the assertion exact without depending on
// how long the test body takes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the inline body comment

This added explanatory comment is inside a test body, but the package guidance for agent-core-v2 only allows comments in the top-of-file header and says not to place them beside functions, methods, or statements. Please move this rationale into the file header or make the assertions self-explanatory without an inline comment.

AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L15-L17

Useful? React with 👍 / 👎.

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.

1 participant