| … | … | @@ -190,7 +190,7 @@ test('receive flow — small file round-trip', async (t) => { |
| 190 | 190 | // Receiver side: start receiving |
| 191 | 191 | const receiverDir = tmpDir('receiver') |
| 192 | 192 | const targetPath = path.join(receiverDir, 'doc.txt') |
| 193 | | const state = transfer.startReceive(targetPath, { size: prepared.size, chunks: prepared.chunks }) |
| 193 | const state = await transfer.startReceive(targetPath, { size: prepared.size, chunks: prepared.chunks }) |
| 194 | 194 | |
| 195 | 195 | t.ok(state.partialPath.endsWith('.overlay-partial')) |
| 196 | 196 | t.is(state.total, 1) |
| … | … | @@ -209,7 +209,7 @@ test('receive flow — small file round-trip', async (t) => { |
| 209 | 209 | t.is(progress.percentage, 100) |
| 210 | 210 | |
| 211 | 211 | // Finalize |
| 212 | | const fin = transfer.finalize(targetPath) |
| 212 | const fin = await transfer.finalize(targetPath) |
| 213 | 213 | t.ok(fin.ok, 'finalized') |
| 214 | 214 | |
| 215 | 215 | // Verify the file on disk |
| … | … | @@ -234,7 +234,7 @@ test('receive flow — multi-chunk file', async (t) => { |
| 234 | 234 | |
| 235 | 235 | const receiverDir = tmpDir('receiver') |
| 236 | 236 | const targetPath = path.join(receiverDir, 'multi.bin') |
| 237 | | transfer.startReceive(targetPath, { size: prepared.size, chunks: prepared.chunks }) |
| 237 | await transfer.startReceive(targetPath, { size: prepared.size, chunks: prepared.chunks }) |
| 238 | 238 | |
| 239 | 239 | // Transfer all chunks |
| 240 | 240 | for (let i = 0; i < prepared.chunks.length; i++) { |
| … | … | @@ -245,7 +245,7 @@ test('receive flow — multi-chunk file', async (t) => { |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | t.ok(transfer.isComplete(targetPath)) |
| 248 | | transfer.finalize(targetPath) |
| 248 | await transfer.finalize(targetPath) |
| 249 | 249 | |
| 250 | 250 | const received = fs.readFileSync(targetPath) |
| 251 | 251 | t.alike(received, original, 'content matches') |
| … | … | @@ -263,7 +263,7 @@ test('receive flow — out-of-order chunks', async (t) => { |
| 263 | 263 | |
| 264 | 264 | const receiverDir = tmpDir('receiver') |
| 265 | 265 | const targetPath = path.join(receiverDir, 'ooo.bin') |
| 266 | | transfer.startReceive(targetPath, { size: prepared.size, chunks: prepared.chunks }) |
| 266 | await transfer.startReceive(targetPath, { size: prepared.size, chunks: prepared.chunks }) |
| 267 | 267 | |
| 268 | 268 | // Send chunks in reverse order |
| 269 | 269 | for (let i = prepared.chunks.length - 1; i >= 0; i--) { |
| … | … | @@ -274,7 +274,7 @@ test('receive flow — out-of-order chunks', async (t) => { |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | t.ok(transfer.isComplete(targetPath)) |
| 277 | | transfer.finalize(targetPath) |
| 277 | await transfer.finalize(targetPath) |
| 278 | 278 | |
| 279 | 279 | const received = fs.readFileSync(targetPath) |
| 280 | 280 | t.alike(received, original, 'content matches even with out-of-order chunks') |
| … | … | @@ -290,7 +290,7 @@ test('writeChunk — rejects bad hash', async (t) => { |
| 290 | 290 | const receiverDir = tmpDir('receiver') |
| 291 | 291 | const targetPath = path.join(receiverDir, 'bad.bin') |
| 292 | 292 | |
| 293 | | transfer.startReceive(targetPath, { |
| 293 | await transfer.startReceive(targetPath, { |
| 294 | 294 | size: 10, |
| 295 | 295 | chunks: [{ hash: 'a'.repeat(64), offset: 0, length: 10 }] |
| 296 | 296 | }) |
| … | … | @@ -312,7 +312,7 @@ test('cancel removes partial file', async (t) => { |
| 312 | 312 | const receiverDir = tmpDir('receiver') |
| 313 | 313 | const targetPath = path.join(receiverDir, 'cancel.bin') |
| 314 | 314 | |
| 315 | | const state = transfer.startReceive(targetPath, { |
| 315 | const state = await transfer.startReceive(targetPath, { |
| 316 | 316 | size: 100, |
| 317 | 317 | chunks: [{ hash: 'h1', offset: 0, length: 100 }] |
| 318 | 318 | }) |
| … | … | @@ -333,7 +333,7 @@ test('finalize rejects incomplete transfer', async (t) => { |
| 333 | 333 | const receiverDir = tmpDir('receiver') |
| 334 | 334 | const targetPath = path.join(receiverDir, 'incomplete.bin') |
| 335 | 335 | |
| 336 | | transfer.startReceive(targetPath, { |
| 336 | await transfer.startReceive(targetPath, { |
| 337 | 337 | size: 200, |
| 338 | 338 | chunks: [ |
| 339 | 339 | { hash: 'h1', offset: 0, length: 100 }, |
| … | … | @@ -341,7 +341,7 @@ test('finalize rejects incomplete transfer', async (t) => { |
| 341 | 341 | ] |
| 342 | 342 | }) |
| 343 | 343 | |
| 344 | | const result = transfer.finalize(targetPath) |
| 344 | const result = await transfer.finalize(targetPath) |
| 345 | 345 | t.is(result.ok, false) |
| 346 | 346 | t.ok(result.error.includes('incomplete')) |
| 347 | 347 | |
| … | … | @@ -357,8 +357,8 @@ test('listActive shows active transfers', async (t) => { |
| 357 | 357 | t.is(transfer.listActive().length, 0) |
| 358 | 358 | |
| 359 | 359 | const dir = tmpDir('receiver') |
| 360 | | transfer.startReceive(path.join(dir, 'a.bin'), { size: 100, chunks: [{ hash: 'h1', offset: 0, length: 100 }] }) |
| 361 | | transfer.startReceive(path.join(dir, 'b.bin'), { size: 200, chunks: [{ hash: 'h2', offset: 0, length: 200 }] }) |
| 360 | await transfer.startReceive(path.join(dir, 'a.bin'), { size: 100, chunks: [{ hash: 'h1', offset: 0, length: 100 }] }) |
| 361 | await transfer.startReceive(path.join(dir, 'b.bin'), { size: 200, chunks: [{ hash: 'h2', offset: 0, length: 200 }] }) |
| 362 | 362 | |
| 363 | 363 | const active = transfer.listActive() |
| 364 | 364 | t.is(active.length, 2) |