Files
vercel__workflow/packages/world-testing/src/idempotency.mts
Nathan Rajlich 6e72b295e7 Add World.getEncryptionKeyForRun and thread encryption key through serialization (#979)
## Summary

- Adds `World.getEncryptionKeyForRun(run)` returning `Uint8Array | undefined` as the interface for retrieving per-run encryption keys
- Updates all 8 dehydrate/hydrate serialization functions to accept `key: Uint8Array | undefined`
- Updates runtime callers, CLI, and tests to thread the key parameter through
2026-02-18 00:53:49 -08:00

35 lines
1011 B
TypeScript

import { expect, test, vi } from 'vitest';
import { hydrateWorkflowReturnValue } from '@workflow/core/serialization';
import { createFetcher, startServer } from './util.mjs';
export function idempotency(world: string) {
test('idempotency', { timeout: 60_000 }, async () => {
const server = await startServer({ world }).then(createFetcher);
const result = await server.invoke('workflows/noop.ts', 'brokenWf', [1, 2]);
expect(result.runId).toMatch(/^wrun_.+/);
const run = await vi.waitFor(
async () => {
const run = await server.getRun(result.runId);
expect(run).toMatchObject<Partial<typeof run>>({
status: 'completed',
});
return run;
},
{
interval: 200,
timeout: 59_000,
}
);
const output = await hydrateWorkflowReturnValue(
run.output!,
run.runId,
undefined
);
expect(output).toEqual({
numbers: Array.from({ length: 20 }, () => expect.any(Number)),
});
});
}