Welcome to mirror list, hosted at ThFree Co, Russian Federation.

download-lsd-magnet.js « node « test - github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8ca10fdeab0eeffa2a9451698b0487fcdee2ef6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import fixtures from 'webtorrent-fixtures'
import MemoryChunkStore from 'memory-chunk-store'
import test from 'tape'
import WebTorrent from '../../index.js'

test('Download using LSD (via magnet uri)', t => {
  t.plan(3)

  const client1 = new WebTorrent({ dht: false, tracker: false, lsd: true })
  const client2 = new WebTorrent({ dht: false, tracker: false, lsd: true })

  client1.on('error', err => { t.fail(err) })
  client1.on('warning', err => { t.fail(err) })

  client2.on('error', err => { t.fail(err) })
  client2.on('warning', err => { t.fail(err) })

  const torrent = client1.add(fixtures.leaves.magnetURI, { store: MemoryChunkStore })

  client2.seed(fixtures.leaves.content, {
    name: 'Leaves of Grass by Walt Whitman.epub',
    announce: []
  })

  torrent.on('done', () => {
    t.pass()

    client1.destroy(err => { t.error(err, 'client 1 destroyed') })
    client2.destroy(err => { t.error(err, 'client 2 destroyed') })
  })
})