Skip to content

Commit 2f14136

Browse files
committed
Add replicate function test
1 parent ab059f4 commit 2f14136

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/networked.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,27 @@ test('download all', async t => {
547547
t.end()
548548
})
549549

550+
test('can swarm with the replicate function', async t => {
551+
const { clients, cleanup } = await createMany(2)
552+
553+
const client1 = clients[0]
554+
const client2 = clients[1]
555+
const corestore1 = client1.corestore()
556+
const corestore2 = client2.corestore()
557+
558+
const core1 = corestore1.get()
559+
await client1.replicate(core1)
560+
await core1.append(Buffer.from('hello world', 'utf8'))
561+
562+
const core2 = corestore2.get(core1.key)
563+
await client2.replicate(core2)
564+
const block = await core2.get(0)
565+
t.same(block.toString('utf8'), 'hello world')
566+
567+
await cleanup()
568+
t.end()
569+
})
570+
550571
function watchDownloadPromise (core, expectedSeq) {
551572
return new Promise((resolve, reject) => {
552573
core.once('download', seq => {

0 commit comments

Comments
 (0)