Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

test: drop tests that guard nothing another test doesn't

Anmol Kapil2e4efd0f65bd
diff --git a/e2e/concurrency.spec.ts b/e2e/concurrency.spec.ts
index fcb92ee..1ecc5f0 100644
--- a/e2e/concurrency.spec.ts
+++ b/e2e/concurrency.spec.ts
@@ -231,11 +231,6 @@ test.describe('stream count', () => {
}
})
- test('networks take turns', () => {
- const { actions } = simulate(capped(1 * MB, 1000 * MB), ['a', 'b'])
- expect(actions.map((action) => action.networkId)).toEqual(['a', 'b', 'a', 'b'])
- })
-
test('new streams the server turns away are retired, and the network grows no further', () => {
const { streams, actions } = simulate(capped(1 * MB, 1000 * MB), ['a'], { accepts: 4 })
expect(streams.get('a')).toBe(4)
@@ -265,10 +260,6 @@ test.describe('stream count', () => {
})
})
- test('a network delivering nothing is not grown', () => {
- expect(simulate(() => new Map([['a', 0]]), ['a']).actions).toEqual([])
- })
-
test('a pause mid-step gives back the untried streams; what was settled stays settled', () => {
const controller = new ConcurrencyController(POLICY)
const tick = (now: number, streams: number, received: number): Action | undefined =>
diff --git a/e2e/download.spec.ts b/e2e/download.spec.ts
index eba0438..b66aa62 100644
--- a/e2e/download.spec.ts
+++ b/e2e/download.spec.ts
@@ -1,4 +1,3 @@
-import { existsSync } from 'node:fs'
import { BLOCK, expect, LAN_ADDRESS, test } from './fixtures'
// A. Downloads that should simply work. Every test also runs the automatic checks in
@@ -91,29 +90,12 @@ test.describe('happy paths @smoke', () => {
}
})
- test('a slow download fills a staging file beside the destination, reporting as it goes', async ({
- plexo,
- serve
- }) => {
- const origin = await serve({ size: 16 * BLOCK, bytesPerSecond: 200_000 })
- const id = await plexo.start(origin.url(), origin.sha256)
- const running = await plexo.waitUntil((state) => state.bytesDownloaded > 0)
- expect(existsSync(`${running.destinationPath}.plexo`)).toBe(true)
- expect(existsSync(running.destinationPath)).toBe(false)
- await plexo.waitForStatus('completed')
- const updates = plexo.sessions
- .at(-1)!
- .filter(
- (state) => state.id === id && state.status === 'downloading' && state.bytesDownloaded > 0
- )
- expect(updates.length, 'progress kept coming while it downloaded').toBeGreaterThan(5)
- })
-
test('after the first, updates carry only the blocks that changed', async ({ plexo, serve }) => {
const origin = await serve({ size: 64 * BLOCK, bytesPerSecond: 500_000 })
const id = await plexo.start(origin.url(), origin.sha256)
await plexo.waitForStatus('completed')
const sent = plexo.updates.at(-1)!.filter((update) => update.state.id === id)
+ expect(sent.length, 'progress kept coming while it downloaded').toBeGreaterThan(5)
expect(sent[0].blocks).toHaveLength(64)
// Two streams move a few blocks between one update and the next, not all 64.
expect(Math.max(...sent.slice(1).map((update) => update.blocks.length))).toBeLessThan(16)
diff --git a/e2e/network.spec.ts b/e2e/network.spec.ts
index aa16413..1de40e5 100644
--- a/e2e/network.spec.ts
+++ b/e2e/network.spec.ts
@@ -87,28 +87,6 @@ test('DNS resolution obeys the request deadline @smoke', async () => {
connection.close()
})
-test('one stream sends request after request down a single connection @smoke', async () => {
- let connections = 0
- const server = createServer((_req, res) => res.end('ok'))
- server.on('connection', () => connections++)
- await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
- const connection = new StreamConnection(loopback, 2000)
- try {
- const url = new URL(`http://127.0.0.1:${(server.address() as AddressInfo).port}/`)
- const reused: boolean[] = []
- for (let i = 0; i < 3; i++) {
- const { req, res } = await connection.request(url, {})
- expect(await body(res)).toBe('ok')
- reused.push(req.reusedSocket)
- }
- expect(reused).toEqual([false, true, true])
- expect(connections).toBe(1)
- } finally {
- connection.close()
- await new Promise<void>((resolve) => server.close(() => resolve()))
- }
-})
-
test('a kept-alive connection the server dropped is replaced without failing the request @smoke', async () => {
let requests = 0
let connections = 0
@@ -132,24 +110,6 @@ test('a kept-alive connection the server dropped is replaced without failing the
}
})
-test('a fresh connection that fails is not retried @smoke', async () => {
- let requests = 0
- const server = createServer((req) => {
- requests++
- req.socket.destroy()
- })
- await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve))
- const connection = new StreamConnection(loopback, 2000)
- try {
- const url = new URL(`http://127.0.0.1:${(server.address() as AddressInfo).port}/`)
- await expect(connection.request(url, {})).rejects.toThrow()
- expect(requests).toBe(1)
- } finally {
- connection.close()
- await new Promise<void>((resolve) => server.close(() => resolve()))
- }
-})
-
test('a request abandoned while still connecting gives up the connection with it @smoke', async () => {
// DNS that never answers stands in for any connect that hangs: the abort has to end it, not the
// deadline.