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

multiple.js « test - github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 93fdde7221f31fa00c168784b6d252ead18f7a5d (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
var WebTorrent = require('../')
var test = require('tape')
var fs = require('fs')

var torrents = [ 'leaves', 'pride' ].map(function (name) {
  return fs.readFileSync(__dirname + '/torrents/' + name + '.torrent')
})

// TODO: replace this with a test that can run offline
test('two simultaneous downloads with dht disabled', function (t) {
  t.plan(torrents.length * 2)

  var client = new WebTorrent({ dht: false })
  var numDone = 0

  client.on('error', function (err) { t.fail(err.message) })

  torrents.forEach(function (torrent) {
    client.add(torrent)
  })

  client.on('torrent', function (torrent) {
    t.pass('received metadata for torrent ' + torrent.name)

    torrent.once('done', function () {
      t.pass('done downloading torrent ' + torrent.name)

      if (++numDone >= torrents.length) {
        client.destroy()
      }
    })
  })
})

test('two simultaneous downloads with dht enabled', function (t) {
  t.plan(torrents.length * 2)

  var client = new WebTorrent()
  var numDone = 0

  client.on('error', function (err) { t.fail(err.message) })

  torrents.forEach(function (torrent) {
    client.add(torrent)
  })

  client.on('torrent', function (torrent) {
    t.pass('received metadata for torrent ' + torrent.name)

    torrent.once('done', function () {
      t.pass('done downloading torrent ' + torrent.name)

      if (++numDone >= torrents.length) {
        client.destroy()
      }
    })
  })
})
*/