mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
6e72b295e7
## 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
35 lines
1011 B
TypeScript
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)),
|
|
});
|
|
});
|
|
}
|