Refactor the app

This commit is contained in:
Schluffe committed 2026-10-28 21:05:47 +01:00
1 parent f53d39ae69
commit 8f82700736
11 files changed
+2032 -235

No files matched your search

+9 -5
View File
@@ -31,7 +31,8 @@ const SIZE = 5_000_000;
const LARGE_SIZE = 2.5 * 2 ** 30;
// Big enough that the transfer still runs while a test cancels or disconnects.
const RUNNING_SIZE = 100_000_000;
// WINDOW, PROBE_TIMEOUT, PROOF_TIMEOUT, CONNECT_TIMEOUT and DOWNLOAD_GRACE in src/core.ts.
// WINDOW, PROBE_TIMEOUT, PROOF_TIMEOUT and CONNECT_TIMEOUT in src/core.ts, DOWNLOAD_GRACE in
// src/download.ts.
const WINDOW = 8 * 2 ** 20;
const PROBE_TIMEOUT = 2000;
const PROOF_TIMEOUT = 10_000;
@@ -329,9 +330,12 @@ async function connect(mode: string, sender: Page, receiver: Page, source: strin
if (mode === 'tracker') return proven(sender, receiver);
const check = (page: Page, side: string) => page.locator(`#check-${side}`).textContent();
await expect(sender.locator('#check-local')).toHaveText(/^([0-9A-F]{2} ){7}[0-9A-F]{2}$/, {
timeout: 45_000,
});
// Each side shows ? until it has that fingerprint, the remote one can come after the local one.
for (const side of ['local', 'remote']) {
await expect(sender.locator(`#check-${side}`)).toHaveText(/^([0-9A-F]{2} ){7}[0-9A-F]{2}$/, {
timeout: 45_000,
});
}
await expect(receiver.locator('#check-remote')).toHaveText((await check(sender, 'local'))!);
await expect(receiver.locator('#check-local')).toHaveText((await check(sender, 'remote'))!);
for (const page of [sender, receiver]) {
@@ -718,7 +722,7 @@ for (const name of Object.keys(BROWSERS)) {
// The edges of the chunking and the window, and a name the Content-Disposition header has to encode.
for (const [what, file, size] of [
// Read whole before the browser takes the download, see DOWNLOAD_GRACE in src/core.ts.
// Read whole before the browser takes the download, see DOWNLOAD_GRACE in src/download.ts.
['an empty file', 'empty.bin', 0],
['a one byte file', 'one.bin', 1],
// Firefox would save a % as _.