Skip to content
This repository was archived by the owner on Dec 28, 2022. It is now read-only.

Commit 2737fc7

Browse files
committed
add failing parallel upload test
1 parent 8778965 commit 2737fc7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/replicate.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,3 +573,28 @@ test('contiguous length after fork', async function (t) {
573573
await b.download({ start: 0, end: a.length }).downloaded()
574574
t.is(b.contiguousLength, 3, 'b has all blocks after fork')
575575
})
576+
577+
test('one inflight request to a peer per block', async function (t) {
578+
const a = await create()
579+
const b = await create(a.key)
580+
581+
let uploads = 0
582+
a.on('upload', function (index) {
583+
if (index === 2) uploads++
584+
})
585+
586+
await a.append(['a', 'b', 'c', 'd', 'e'])
587+
588+
replicate(a, b, t)
589+
590+
await eventFlush()
591+
592+
const r1 = b.get(2)
593+
await Promise.resolve()
594+
const r2 = b.get(2)
595+
596+
await r1
597+
await r2
598+
599+
t.is(uploads, 1)
600+
})

0 commit comments

Comments
 (0)