diff options
Diffstat (limited to 'packages/meshbay-hub/tests/harness')
4 files changed, 20 insertions, 5 deletions
diff --git a/packages/meshbay-hub/tests/harness/chat_send_probe.py b/packages/meshbay-hub/tests/harness/chat_send_probe.py index d343c50..7569628 100644 --- a/packages/meshbay-hub/tests/harness/chat_send_probe.py +++ b/packages/meshbay-hub/tests/harness/chat_send_probe.py @@ -77,6 +77,9 @@ import threading import time from pathlib import Path +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) +from spa_source import transport_files # noqa: E402 + STATIC = Path(__file__).resolve().parents[2] / "src" / "meshbay_hub" / "static" PORT = 8755 RECORDS = [] @@ -104,7 +107,10 @@ def _page() -> str: .replace("__GROUP_ID__", GROUP_ID) .replace("__GEK_HEX__", GEK.hex()) .replace("__KEYS_NONCE_HEX__", sealed["nonce"].hex()) - .replace("__KEYS_CT_HEX__", sealed["ct"].hex())) + .replace("__KEYS_CT_HEX__", sealed["ct"].hex()) + # transport.js and the parts split out of it, in the shell's order. + .replace("__TRANSPORT_SCRIPTS__", "\n".join( + f'<script src="/{p.name}"></script>' for p in transport_files()))) PAGE_TEMPLATE = r"""<!doctype html><html><head><meta charset=utf-8> <link rel="stylesheet" href="/style.css"></head> @@ -119,7 +125,7 @@ PAGE_TEMPLATE = r"""<!doctype html><html><head><meta charset=utf-8> Without them a send fails with "cannot read properties of undefined". --> <script src="/crypto.js"></script> <script src="/keyderive.js"></script> -<script src="/transport.js"></script> +__TRANSPORT_SCRIPTS__ <script type="module"> import { html, render, useRef, useState, useEffect } from '/vendor/htm-preact.js'; import { ChatPanel } from '/chat-app.js'; diff --git a/packages/meshbay-hub/tests/harness/index_seal_probe.mjs b/packages/meshbay-hub/tests/harness/index_seal_probe.mjs index 36302bb..2493a05 100644 --- a/packages/meshbay-hub/tests/harness/index_seal_probe.mjs +++ b/packages/meshbay-hub/tests/harness/index_seal_probe.mjs @@ -21,6 +21,7 @@ * the outstanding request ended. */ import fs from 'fs'; +import { delimiter } from 'path'; const STATIC = process.argv[2]; const input = JSON.parse(fs.readFileSync(process.argv[3], 'utf8')); @@ -41,7 +42,10 @@ globalThis.document = { }; new Function(fs.readFileSync(`${STATIC}/crypto.js`, 'utf8'))(); -new Function(fs.readFileSync(`${STATIC}/transport.js`, 'utf8'))(); +// argv[4]: transport.js and the parts split out of it, joined as one scope. +const transportSrc = process.argv[4].split(delimiter) + .map((p) => fs.readFileSync(p, 'utf8')).join('\n'); +new Function(transportSrc)(); const hex = (s) => Uint8Array.from(s.match(/../g).map((b) => parseInt(b, 16))); diff --git a/packages/meshbay-hub/tests/harness/offer_retry_harness.mjs b/packages/meshbay-hub/tests/harness/offer_retry_harness.mjs index 3a4b568..3e8233b 100644 --- a/packages/meshbay-hub/tests/harness/offer_retry_harness.mjs +++ b/packages/meshbay-hub/tests/harness/offer_retry_harness.mjs @@ -6,8 +6,10 @@ // // Usage: node offer_retry_harness.mjs <path to transport.js> <json config> import { readFileSync } from 'fs'; +import { delimiter } from 'path'; -const src = readFileSync(process.argv[2], 'utf8'); +// transport.js and the parts split out of it, joined. +const src = process.argv[2].split(delimiter).map((p) => readFileSync(p, 'utf8')).join('\n'); const cfg = JSON.parse(process.argv[3] || '{}'); const { diff --git a/packages/meshbay-hub/tests/harness/upload_seal_probe.mjs b/packages/meshbay-hub/tests/harness/upload_seal_probe.mjs index 0fe7554..60ec48a 100644 --- a/packages/meshbay-hub/tests/harness/upload_seal_probe.mjs +++ b/packages/meshbay-hub/tests/harness/upload_seal_probe.mjs @@ -21,6 +21,7 @@ * seal, so the ciphertext stays exactly the one Python produced. */ import fs from 'fs'; +import { delimiter } from 'path'; const STATIC = process.argv[2]; const input = JSON.parse(fs.readFileSync(process.argv[3], 'utf8')); @@ -38,7 +39,9 @@ globalThis.document = { }; new Function(fs.readFileSync(`${STATIC}/crypto.js`, 'utf8'))(); -const transportSrc = fs.readFileSync(`${STATIC}/transport.js`, 'utf8'); +// argv[4]: transport.js and the parts split out of it, joined as one scope. +const transportSrc = process.argv[4].split(delimiter) + .map((p) => fs.readFileSync(p, 'utf8')).join('\n'); new Function(transportSrc)(); // The msgpack codec is private to transport.js — pulled out the same way the // groupbox parity harness pulls out sealGroup, so this probe encodes and |