mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
test: follow the uuid mint to its new entropy seam
This commit is contained in:
@@ -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
|
||||
})
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user