test(serve): pin the output memo to returning the stored string

A memo hit must not re-render. The generated stamp is minted per render,
so asserting it is unchanged across the hit states that contract directly
instead of leaving it implied by byte equality.
This commit is contained in:
iamtoruk 2026-08-17 00:09:38 -07:00
parent 966454d774
commit 0bed44fec8

View file

@ -281,6 +281,11 @@ describe('codeburn serve --stdio', () => {
const sameBytes = await request(110, args)
expect(sameBytes['ok']).toBe(true)
expect(sameBytes['output']).toBe(memoized!['output'])
// `generated` is minted per render, so an unchanged stamp is the proof
// that a memo hit returns the stored string instead of re-rendering.
const stamp = (res: Record<string, unknown>): string =>
(JSON.parse(res['output'] as string) as { generated: string }).generated
expect(stamp(sameBytes)).toBe(stamp(memoized!))
// Same byte length as USD: a size-only fingerprint would miss this.
await writeFile(configPath, JSON.stringify({ currency: { code: 'EUR' } }), 'utf8')