From f910e4f84fe04262f89335ddaac219a3d9f0b57f Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Fri, 21 Aug 2026 02:46:37 +0800 Subject: [PATCH] test: follow the uuid mint to its new entropy seam --- apps/web/tests/hmr-live.e2e.ts | 5 +++-- packages/schedule/schedule/tests/runtime.spec.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/web/tests/hmr-live.e2e.ts b/apps/web/tests/hmr-live.e2e.ts index bf7a3123db..97fe5d5833 100644 --- a/apps/web/tests/hmr-live.e2e.ts +++ b/apps/web/tests/hmr-live.e2e.ts @@ -2,7 +2,6 @@ import { existsSync, globSync } from 'node:fs' import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' -import { randomUUID } from 'node:crypto' import { tmpdir } from 'node:os' import { join } from 'node:path' import { chromium } from 'playwright' @@ -115,7 +114,9 @@ it('hot-reloads a real client-plugin source edit without refreshing the page', a await page.goto(baseUrl, { waitUntil: 'load' }) await page.getByText(oldText, { exact: true }).waitFor({ timeout: 15_000 }) const pageIdentity = await page.evaluate(() => { - const identity = randomUUID() + // In-page code: an import would not survive serialization, and the page + // entropy source available in every context is getRandomValues. + const identity = Array.from(crypto.getRandomValues(new Uint8Array(8)), byte => byte.toString(16).padStart(2, '0')).join('') Object.defineProperty(window, '__dshHmrPageIdentity', { value: identity }) return identity }) diff --git a/packages/schedule/schedule/tests/runtime.spec.ts b/packages/schedule/schedule/tests/runtime.spec.ts index d49f33b715..609c68a6cd 100644 --- a/packages/schedule/schedule/tests/runtime.spec.ts +++ b/packages/schedule/schedule/tests/runtime.spec.ts @@ -679,7 +679,9 @@ describe('Schedule runtime failure and teardown boundaries', () => { const runFailure = await harness() appendAfter(runFailure, 'schedule-1', 1, Date.now() - 1_000) - const uuidSpy = vi.spyOn(globalThis.crypto, 'randomUUID').mockImplementation(() => { throw 'message failed' }) + // The reminder message mints its id through dsh-util-crypto, whose + // entropy source is getRandomValues — the failure injection follows it. + const uuidSpy = vi.spyOn(globalThis.crypto, 'getRandomValues').mockImplementation(() => { throw 'message failed' }) const failingRuntime = runtimeFor(runFailure) failingRuntime.start() for (let index = 0; index < 12; index += 1) await Promise.resolve() @@ -690,7 +692,7 @@ describe('Schedule runtime failure and teardown boundaries', () => { const departedRun = await harness() appendAfter(departedRun, 'schedule-1', 1, Date.now() - 1_000) - const departedUuidSpy = vi.spyOn(globalThis.crypto, 'randomUUID').mockImplementation(() => { + const departedUuidSpy = vi.spyOn(globalThis.crypto, 'getRandomValues').mockImplementation(() => { departedRun.disposeAgent() throw 'message failed after detach' })