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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-01-15 04:21:23 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-01-15 04:21:23 +0300
commit7bde207ca9ea2d539daf7304c447639f8a513d0d (patch)
tree885c1917b334736c6a56bd2f2a6aa6478b4c5555 /test
parent6f89456317a5383d07e5041b049497c9f5151335 (diff)
add more tests for duplicate trackers
For #571. Still can’t reproduce the issue
Diffstat (limited to 'test')
-rw-r--r--test/client-add-duplicate-trackers.js70
1 files changed, 69 insertions, 1 deletions
diff --git a/test/client-add-duplicate-trackers.js b/test/client-add-duplicate-trackers.js
index 66e8fd2..70cec07 100644
--- a/test/client-add-duplicate-trackers.js
+++ b/test/client-add-duplicate-trackers.js
@@ -1,8 +1,9 @@
var common = require('./common')
+var extend = require('xtend')
var test = require('tape')
var WebTorrent = require('../')
-test('client.add: magnet uri, utf-8 string', function (t) {
+test('client.add: duplicate trackers', function (t) {
t.plan(3)
var client = new WebTorrent({ dht: false, tracker: false })
@@ -20,3 +21,70 @@ test('client.add: magnet uri, utf-8 string', function (t) {
client.destroy(function (err) { t.error(err, 'client destroyed') })
})
})
+
+test('client.add: duplicate trackers, with multiple torrents', function (t) {
+ t.plan(5)
+
+ // Re-use this object, in case webtorrent is changing it
+ var opts = {
+ announce: [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ }
+
+ var client = new WebTorrent({ dht: false, tracker: false })
+
+ client.on('error', function (err) { t.fail(err) })
+ client.on('warning', function (err) { t.fail(err) })
+
+ var torrent1 = client.add(common.leaves.torrent, opts)
+
+ torrent1.on('ready', function () {
+ t.equal(torrent1.magnetURI, common.leaves.magnetURI + '&tr=' + encodeURIComponent('wss://example.com'))
+
+ var torrent2 = client.add(common.alice.torrent, opts)
+
+ torrent2.on('ready', function () {
+ t.equal(torrent2.magnetURI, common.alice.magnetURI + '&tr=' + encodeURIComponent('wss://example.com'))
+
+ torrent1.destroy(function (err) { t.error(err, 'torrent1 destroyed') })
+ torrent2.destroy(function (err) { t.error(err, 'torrent2 destroyed') })
+ client.destroy(function (err) { t.error(err, 'client destroyed') })
+ })
+ })
+})
+
+test('client.add: duplicate trackers (including in .torrent file), multiple torrents', function (t) {
+ t.plan(5)
+
+ // Re-use this object, in case webtorrent is changing it
+ var opts = {
+ announce: [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+ }
+
+ // Include the duplicate trackers in the .torrent files
+ var parsedTorrentLeaves = extend(common.leaves.parsedTorrent)
+ parsedTorrentLeaves.announce = [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+
+ var parsedTorrentAlice = extend(common.alice.parsedTorrent)
+ parsedTorrentAlice.announce = [ 'wss://example.com', 'wss://example.com', 'wss://example.com' ]
+
+ var client = new WebTorrent({ dht: false, tracker: false })
+
+ client.on('error', function (err) { t.fail(err) })
+ client.on('warning', function (err) { t.fail(err) })
+
+ var torrent1 = client.add(parsedTorrentLeaves, opts)
+
+ torrent1.on('ready', function () {
+ t.equal(torrent1.magnetURI, common.leaves.magnetURI + '&tr=' + encodeURIComponent('wss://example.com'))
+
+ var torrent2 = client.add(parsedTorrentAlice, opts)
+
+ torrent2.on('ready', function () {
+ t.equal(torrent2.magnetURI, common.alice.magnetURI + '&tr=' + encodeURIComponent('wss://example.com'))
+
+ torrent1.destroy(function (err) { t.error(err, 'torrent1 destroyed') })
+ torrent2.destroy(function (err) { t.error(err, 'torrent2 destroyed') })
+ client.destroy(function (err) { t.error(err, 'client destroyed') })
+ })
+ })
+})