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

duplicate.js « test - github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ca06b3daca5ef84d1c812b4bb370753707251662 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// var fixtures = require('webtorrent-fixtures')
// var test = require('tape')
// var WebTorrent = require('../')

// test('client.seed followed by duplicate client.add', function (t) {
//   t.plan(6)

//   var client = new WebTorrent({ dht: false, tracker: false })
//   client.on('error', function (err) { t.fail(err) })
//   client.on('warning', function (err) { t.fail(err) })

//   client.seed(fixtures.leaves.content, {
//     name: 'Leaves of Grass by Walt Whitman.epub',
//     announce: []
//   }, function (torrent1) {
//     t.equal(client.torrents.length, 1)

//     var torrent2 = client.add(torrent1.infoHash)

//     torrent2.once('ready', function () {
//       t.fail('torrent ready is not called')
//     })

//     torrent2.once('error', function (err) {
//       t.ok(err, 'got expected error on duplicate add')
//       t.equal(client.torrents.length, 1)
//       t.ok(torrent2.destroyed)
//       client.destroy(function (err) {
//         t.error(err, 'destroyed client')
//         t.equal(client.torrents.length, 0)
//       })
//     })
//   })
// })

// TODO
// test('client.seed followed by two duplicate client.add calls', function (t) {
//   t.plan(9)

//   var client = new WebTorrent({ dht: false, tracker: false })
//   client.on('error', function (err) { t.fail(err) })
//   client.on('warning', function (err) { t.fail(err) })

//   client.seed(fixtures.leaves.content, {
//     name: 'Leaves of Grass by Walt Whitman.epub',
//     announce: []
//   }, function (torrent1) {
//     t.equal(client.torrents.length, 1)

//     var torrent2 = client.add(torrent1.infoHash)

//     torrent2.once('ready', function () {
//       t.fail('torrent ready is not called')
//     })

//     torrent2.once('error', function (err) {
//       t.ok(err, 'got expected error on duplicate add')
//       t.equal(client.torrents.length, 1)
//       t.ok(torrent2.destroyed)

//       var torrent3 = client.add(torrent1.infoHash)

//       torrent3.once('ready', function () {
//         t.fail('torrent ready is not called')
//       })

//       torrent3.once('error', function (err) {
//         t.ok(err, 'got expected error on duplicate add')
//         t.equal(client.torrents.length, 1)
//         t.ok(torrent3.destroyed)
//         client.destroy(function (err) {
//           t.error(err, 'destroyed client')
//           t.equal(client.torrents.length, 0)
//         })
//       })
//     })
//   })
// })

// TODO
// test('successive sync client.add, client.remove, client.add, client.remove', function (t) {
//   t.plan(3)

//   var client = new WebTorrent({ dht: false, tracker: false })
//   client.on('error', function (err) { t.fail(err) })
//   client.on('warning', function (err) { t.fail(err) })

//   client.seed(fixtures.leaves.content, {
//     name: 'Leaves of Grass by Walt Whitman.epub',
//     announce: []
//   }, function (torrent1) {
//     t.equal(client.torrents.length, 1)

//     client.add(torrent1.infoHash)
//     client.remove(torrent1.infoHash)
//     client.add(torrent1.infoHash)
//     client.remove(torrent1.infoHash, function () {
//       client.destroy(function (err) {
//         t.error(err, 'destroyed client')
//         t.equal(client.torrents.length, 0)
//       })
//     })
//   })
// })