components
All repositories: gitoria
3.4 KB
// Mirrors ws-handshake-order.mjs: exercise the built plugin over real sockets.import { spawn, spawnSync } from 'node:child_process';import { readlinkSync } from 'node:fs';import { once } from 'node:events';import assert from 'node:assert/strict';import { fileURLToPath } from 'node:url';import { resolve, dirname } from 'node:path';const HERE = dirname(fileURLToPath(import.meta.url));const ROOT = resolve(HERE, '../../..');const PORT = Number(process.env.HL_TEST_PORT || 30090);const BIN = process.env.HL_BIN || resolve(ROOT, 'native/zig-out/bin/hybriel');const server = spawn(BIN, [resolve(HERE, 'two-ws-servers.hl')], { cwd: ROOT, env: { ...process.env, HL_TEST_PORT: String(PORT) }, stdio: ['ignore', 'pipe', 'pipe'] });let log = '', checks = 0;server.stdout.on('data', d => { log += d; });server.stderr.on('data', d => { log += d; });const peers = [];const sleep = ms => new Promise(r => setTimeout(r, ms));const get = (port, path = '/') => fetch(`http://127.0.0.1:${port}${path}`).then(r => r.text());function check(actual, expected) { assert.deepEqual(actual, expected); checks++; }async function waitFor(fn) {for (let i = 0; i < 150; i++) { if (await fn()) return; await sleep(20); }throw new Error('timeout\n' + log);}function peer(port) {const ws = new WebSocket(`ws://127.0.0.1:${port}/`);ws.messages = [];ws.addEventListener('message', e => ws.messages.push(String(e.data)));peers.push(ws);return ws;}try {await waitFor(async () => { try { return await get(PORT) === '0:0'; } catch { return false; } });const a1 = peer(PORT), a2 = peer(PORT), b = peer(PORT + 1);await waitFor(() => peers.every(p => p.messages.length >= 1));check(a1.messages, ['open:A']); check(a2.messages, ['open:A']); check(b.messages, ['open:B']);a1.send('one'); a2.send('two'); b.send('three');await waitFor(() => peers.every(p => p.messages.length >= 2));check(a1.messages, ['open:A', 'A:one']); check(a2.messages, ['open:A', 'A:two']); check(b.messages, ['open:B', 'B:three']);check(await get(PORT, '/broadcast'), '2');await waitFor(() => a1.messages.length === 3 && a2.messages.length === 3);check(await get(PORT + 1, '/broadcast'), '1');await waitFor(() => b.messages.length === 3);await sleep(100);check(a1.messages, ['open:A', 'A:one', 'broadcast:A']);check(a2.messages, ['open:A', 'A:two', 'broadcast:A']);check(b.messages, ['open:B', 'B:three', 'broadcast:B']);a1.close(); await once(a1, 'close');await waitFor(async () => await get(PORT) === '1:0'); check(await get(PORT + 1), '1:0');b.close(); await once(b, 'close');await waitFor(async () => await get(PORT + 1) === '1:1'); check(await get(PORT), '1:1');const b2 = peer(PORT + 1); await waitFor(() => b2.messages.length === 1); check(b2.messages, ['open:B']);await get(PORT, '/stop');b2.send('survives'); await waitFor(() => b2.messages.length === 2); check(b2.messages, ['open:B', 'B:survives']);check(await get(PORT + 1, '/broadcast'), '1'); await waitFor(() => b2.messages.length === 3);check(b2.messages, ['open:B', 'B:survives', 'broadcast:B']);console.log(`ok two-ws-servers: ${checks} checks`);} finally {for (const p of peers) p.close();if (server.exitCode === null) {const stopped = once(server, 'exit');assert.equal(readlinkSync(`/proc/${server.pid}/cwd`), ROOT);spawnSync('ss', ['-ltnp', `( sport = ${PORT} or sport = ${PORT + 1} )`]);server.kill('SIGTERM');await stopped;}}
Branches
Latest commits
- b7e11e3bvirtual-list: the first resetKey is the baseline, so centerId and scrollTop keep their place at mount; gate for itAtlas
- 7e428ba6Re-vendor Hybriel day72 (day73 withdrawn: minifier breaks write sets)Atlas
- a06fc778Reset virtual-list window when the host changes resetKeyAtlas
- 3aab598cRe-vendor complete Hybriel day73 set for virtual-list resetAtlas
- 337ca075MD1 gate check measures frames in the page, not milliseconds from outside, and takes the middle load (components#30)mre
- f5f131c5Record AP29 autoplay comparisons and passing gatesmre
- 51c38187Gate media autoplay on first load and after client mountmre
- a3f2223dRecord successful B44 deployment and live proofmre
- 06c1e021Record passing B44 browser rerunmre
- c9861533Record B44 component proof and browser gate blockermre
- 1b7413beIgnore detached media events and space demo option outputsmre
- ca3b4959Re-vendor complete Hybriel plugins and runtime to day44mre
- df9e7df9Last-item checks run in the browser gate (components#26 fixed on day41); media-player loop is a plain Booleanmre
- 895a5afcRe-vendor complete Hybriel plugins and runtime to day41mre
- 16006bb3Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 88397fc3Re-vendor complete Hybriel plugins and runtime to day39mre
- 9b872cedRecord IC28 deployment and live icon verificationmre
- 46fefaa7Count the icons entry in the offline home-page checkmre
- c7e14cabRecord IC28 rerun and unchanged-main baseline comparisonmre
- 5e090ffdRecord IC28 review evidence and gate resultsmre