Queue executable speed and peer-to-peer sharing plans with tested patches and harnesses
This commit is contained in:
21
plans/harness/rehydrate-check.mjs
Normal file
21
plans/harness/rehydrate-check.mjs
Normal file
@@ -0,0 +1,21 @@
|
||||
// Plan 018 harness check: a holder is asked to restore an evicted copy.
|
||||
import { chromium } from 'playwright';
|
||||
const b = await chromium.launch({ executablePath: process.env.CHROMIUM || '/opt/pw-browsers/chromium-1194/chrome-linux/chrome' });
|
||||
const p = await b.newPage();
|
||||
await p.goto('http://localhost:8771/');
|
||||
const out = await p.evaluate(async () => {
|
||||
const bytes = new Uint8Array(await (await fetch('/fixture.mp4')).arrayBuffer());
|
||||
const dir = await (await navigator.storage.getDirectory()).getDirectoryHandle('videos', { create: true });
|
||||
const w = await (await dir.getFileHandle('goneAAAAAAA.mp4', { create: true })).createWritable();
|
||||
await w.write(bytes); await w.close();
|
||||
P2PClient.start({ getSettings: () => ({}) });
|
||||
const rep = await P2PClient.sync(); // hashes the file, reports it → accepted (cid is verified content)
|
||||
for (let i = 0; i < 50 && !P2PClient.isConnected(); i++) await new Promise((r) => setTimeout(r, 100));
|
||||
const s1 = await (await fetch('/api/streams?v=goneAAAAAAA')).json();
|
||||
let dbg;
|
||||
for (let i = 0; i < 50; i++) { dbg = await (await fetch('/debug')).json(); if (dbg.adopted.length) break; await new Promise((r) => setTimeout(r, 200)); }
|
||||
const s2 = await (await fetch('/api/streams?v=goneAAAAAAA')).json();
|
||||
return { accepted: rep.accepted.length, first: s1, adopted: dbg.adopted.map((a) => [a.videoId, a.sha256 === dbg.cid]), second: s2 };
|
||||
});
|
||||
console.log(JSON.stringify(out));
|
||||
await b.close();
|
||||
Reference in New Issue
Block a user