Skip to content

Commit 80511fa

Browse files
loganjLarry
andauthored
test(relay): hold the first slow publish for a fixed interval (#261)
Signed-off-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
1 parent 0ec4196 commit 80511fa

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/features/relay/broker.integration.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ it("profiles a first slow publish through real local IPC, signing, authenticated
106106
.find((sample) => sample.stage === "send.publish" && sample.id === first);
107107
expect(pending).toMatchObject({ outcome: "pending" });
108108
expect(uploaded).toBe(1);
109+
// Hold the first publish long enough that it is slow by construction, not
110+
// by comparison with a second publish on a loaded runner.
111+
const heldAt = performance.now();
112+
await new Promise((resolve) => setTimeout(resolve, 200));
113+
const heldMs = performance.now() - heldAt;
109114
release();
110115
await vi.waitFor(() => expect(outbox.snapshot()).toHaveLength(0), {
111116
timeout: 3000,
@@ -124,7 +129,7 @@ it("profiles a first slow publish through real local IPC, signing, authenticated
124129
(sample) => sample.id === second && sample.stage === "send.publish",
125130
);
126131
assert.exists(secondUpstream);
127-
expect(firstUpstream.duration).toBeGreaterThan(0);
132+
expect(firstUpstream.duration).toBeGreaterThanOrEqual(heldMs);
128133
expect(secondUpstream.duration).toBeLessThan(firstUpstream.duration);
129134
expect(events.get(first)).toMatchObject({
130135
content: `first\n\n[report.pdf](<${fixtureRelayUrl}/media/${hash}.pdf>)`,

0 commit comments

Comments
 (0)