diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:51:35 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-17 18:51:35 +0200 |
| commit | 7e01b7e8c2ce2ef9fce8b6c053c3b7210b64f9bf (patch) | |
| tree | 9b5d0aae04e226e1f3c7187a4866ee421544f7a4 /packages/meshbay-hub/tests/harness/search_connect_harness.mjs | |
| parent | 8125df6d8149368ed8a84c9db6c5e37bfccb5a15 (diff) | |
| download | meshbay-7e01b7e8c2ce2ef9fce8b6c053c3b7210b64f9bf.tar.gz | |
fix(spa): search names the groups refused the local network
Search gives up before ICE does, so the refusal is read from the
connection then; the walk moves on to the group's other nodes, and the
page lists the refused groups with a link to each.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/tests/harness/search_connect_harness.mjs')
| -rw-r--r-- | packages/meshbay-hub/tests/harness/search_connect_harness.mjs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/packages/meshbay-hub/tests/harness/search_connect_harness.mjs b/packages/meshbay-hub/tests/harness/search_connect_harness.mjs index 60cea2ba..71c7e8c4 100644 --- a/packages/meshbay-hub/tests/harness/search_connect_harness.mjs +++ b/packages/meshbay-hub/tests/harness/search_connect_harness.mjs @@ -26,6 +26,11 @@ const { resolveAt = null, // How many nodes the hub lists for the group. nodes = 1, + // Which of them answer (resolveAt applies to these). null: all. + answering = null, + // Which of them this device refuses to reach on the local network: what the + // transport reads from its connection when search gives up on it. + lanRefused = [], // How far to run the clock before giving up on the harness itself. runUntil = 300000, } = cfg; @@ -65,13 +70,17 @@ async function run(until) { // ── The environment ────────────────────────────────────────────────────────── let closed = 0; +let made = 0; class FakeTransport { constructor() { this.onConnectProgress = null; this.onNeedToken = null; + this.index = made++; } + async localNetworkRefused() { return lanRefused.includes(this.index); } + connect() { const started = now; for (const at of progressAt) { @@ -84,7 +93,7 @@ class FakeTransport { }, at); } return new Promise((resolve) => { - if (resolveAt !== null) { + if (resolveAt !== null && (answering === null || answering.includes(this.index))) { setTimeout(() => resolve({ ok: true, at: now - started }), resolveAt); } }); @@ -127,7 +136,9 @@ const connectToGroup = make(hubFetch, ensureFreshToken, globalThis.window); let outcome = null; connectToGroup('https://hub.example', 'g1', 'tok', null, 'alice', 'u1') .then(() => { outcome = { result: 'connected', at: now }; }) - .catch((e) => { outcome = { result: 'failed', at: now, error: String(e.message) }; }); + .catch((e) => { + outcome = { result: 'failed', at: now, error: String(e.message), reason: e.reason || null }; + }); await run(runUntil); |