Queue executable speed and peer-to-peer sharing plans with tested patches and harnesses
This commit is contained in:
26
plans/harness/p2p-client-check.mjs
Normal file
26
plans/harness/p2p-client-check.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
// Plan 013 harness check (see device-db-check.mjs for requirements).
|
||||
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();
|
||||
p.on('console', (m) => { if (m.type() === 'error') console.log('console:', m.text()); });
|
||||
await p.goto('http://localhost:8767/');
|
||||
const out = await p.evaluate(async () => {
|
||||
const good = await OPFS.downloadVideo('goodAAAAAAA', '/api/download/goodAAAAAAA');
|
||||
// A legacy save: in OPFS but no DeviceDB record, unknown to the server.
|
||||
const dir = await (await navigator.storage.getDirectory()).getDirectoryHandle('videos', { create: true });
|
||||
const w = await (await dir.getFileHandle('legacyAAAAA.mp4', { create: true })).createWritable();
|
||||
await w.write(new Uint8Array(1000).fill(9)); await w.close();
|
||||
await DeviceDB.putFile({ videoId: 'goodAAAAAAA', cid: good.sha256, size: good.size, state: 'unverified' });
|
||||
await DeviceDB.putFile({ videoId: 'ghostAAAAAA', cid: 'e'.repeat(64), size: 5, state: 'verified' }); // no file
|
||||
P2PClient.start({ getSettings: () => ({}) });
|
||||
const res = await P2PClient.sync();
|
||||
const recs = (await DeviceDB.listFiles()).map((r) => [r.videoId, r.state, !!r.cid]).sort();
|
||||
const holders = await (await fetch('/debug/holders')).json();
|
||||
// Turn sharing off → full withdrawal.
|
||||
P2PClient.start({ getSettings: () => ({ p2pShare: false }) });
|
||||
await P2PClient.sync();
|
||||
const after = await (await fetch('/debug/holders')).json();
|
||||
return { accepted: res && res.accepted.length, unknown: res && res.unknown.length, challenges: res && res.challenges.length, recs, trust: holders.map((h) => h.trust), afterShareOff: after.length, device: !!P2PClient.device() };
|
||||
});
|
||||
console.log(JSON.stringify(out));
|
||||
await b.close();
|
||||
Reference in New Issue
Block a user