Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/core/test/unit/runtime/service.auto-accept.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,12 @@ describe("connection request auto-accept (spec §1.5)", () => {
senderInboxId: "peer-inbox-hook-invalid",
message: request,
});
await sleep(50);

// Wait until the rejection response has been sent — that proves the
// async processing completed, making the negative assertion deterministic.
await waitForCondition("rejected connection/result sent", () =>
transport.sentMessages.some((m) => m.message.method === "connection/result"),
Comment on lines +422 to +423

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require the rejected status before asserting the hook stayed idle

In this test, the predicate accepts any connection/result, including an accidental accepted result. The accepted path sends the result before it writes the contact and awaits onConnectionEstablished, so this wait can return as soon as FakeTransport.send() records the message and the negative assertion can run before the hook is invoked. In the invalid-invite scenario this means a regression that accepts the invite could pass; check the result params/status is "rejected" before returning from the wait.

Useful? React with 👍 / 👎.

);

expect(onConnectionEstablished).not.toHaveBeenCalled();

Expand Down
6 changes: 4 additions & 2 deletions packages/core/test/unit/runtime/service.waiters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,10 @@ describe("connect waiter lifecycle (spec §3.2 + Task 4.1)", () => {
// registered inside connect() before it awaits the waiterPromise.
const connectPromise = service.connect({ inviteUrl: url, waitMs: 10_000 });

// Give connect() time to register the waiter and reach the await.
await sleep(50);
// Wait until connect() has sent the connection/request — the waiter is
// registered immediately before transport.send(), so observing the sent
// message guarantees the waiter exists.
await waitFor(() => transport.sentMessages.length === 1);

// Stop the service. This calls rejectAllConnectWaiters() which rejects the
// waiter, causing connectInternal to throw, which propagates to connect().
Expand Down