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/node
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-02-28 06:10:08 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-02-28 06:10:08 +0300
commitff552814b86d11c171226c20efd9c9d1c3d968be (patch)
tree13721145118b68b20ca6eaa478ba259cab703252 /test/node
parent0d2dc8c90900d1ea2103f6a457c76c7998eab3a6 (diff)
use webtorrent-fixtures
Diffstat (limited to 'test/node')
-rw-r--r--test/node/basic.js32
-rw-r--r--test/node/blocklist-dht.js6
-rw-r--r--test/node/blocklist-tracker.js4
-rw-r--r--test/node/blocklist.js32
-rw-r--r--test/node/cmd.js12
-rw-r--r--test/node/download-dht-magnet.js10
-rw-r--r--test/node/download-dht-torrent.js10
-rw-r--r--test/node/download-private-dht.js6
-rw-r--r--test/node/download-tracker-magnet.js8
-rw-r--r--test/node/download-tracker-torrent.js8
-rw-r--r--test/node/download-webseed-magnet.js10
-rw-r--r--test/node/download-webseed-torrent.js8
-rw-r--r--test/node/duplicates.js8
-rw-r--r--test/node/extensions.js6
-rw-r--r--test/node/metadata.js8
-rw-r--r--test/node/seed-stream.js4
-rw-r--r--test/node/seed-while-download.js18
-rw-r--r--test/node/server.js8
18 files changed, 98 insertions, 100 deletions
diff --git a/test/node/basic.js b/test/node/basic.js
index 6bee61c..6b32fff 100644
--- a/test/node/basic.js
+++ b/test/node/basic.js
@@ -1,4 +1,4 @@
-var common = require('../common')
+var fixtures = require('webtorrent-fixtures')
var http = require('http')
var test = require('tape')
var WebTorrent = require('../../')
@@ -23,7 +23,7 @@ test('client.add: http url to a torrent file, string', function (t) {
var server = http.createServer(function (req, res) {
t.ok(req.headers['user-agent'].indexOf('WebTorrent') !== -1)
- res.end(common.leaves.torrent)
+ res.end(fixtures.leaves.torrent)
})
server.listen(0, function () {
@@ -36,8 +36,8 @@ test('client.add: http url to a torrent file, string', function (t) {
client.add(url, function (torrent) {
t.equal(client.torrents.length, 1)
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
client.remove(torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -56,10 +56,10 @@ test('client.add: filesystem path to a torrent file, string', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.add(common.leaves.torrentPath, function (torrent) {
+ client.add(fixtures.leaves.torrentPath, function (torrent) {
t.equal(client.torrents.length, 1)
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
client.remove(torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -76,12 +76,12 @@ test('client.seed: filesystem path to file, string', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(common.leaves.contentPath, {
+ client.seed(fixtures.leaves.contentPath, {
name: 'Leaves of Grass by Walt Whitman.epub'
}, function (torrent) {
t.equal(client.torrents.length, 1)
- t.equal(torrent.infoHash, common.leaves.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.leaves.magnetURI)
+ t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
client.remove(torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -98,10 +98,10 @@ test('client.seed: filesystem path to folder with one file, string', function (t
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(common.folder.contentPath, function (torrent) {
+ client.seed(fixtures.folder.contentPath, function (torrent) {
t.equal(client.torrents.length, 1)
- t.equal(torrent.infoHash, common.folder.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.folder.magnetURI)
+ t.equal(torrent.infoHash, fixtures.folder.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.folder.magnetURI)
client.remove(torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -118,10 +118,10 @@ test('client.seed: filesystem path to folder with multiple files, string', funct
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(common.numbers.contentPath, function (torrent) {
+ client.seed(fixtures.numbers.contentPath, function (torrent) {
t.equal(client.torrents.length, 1)
- t.equal(torrent.infoHash, common.numbers.parsedTorrent.infoHash)
- t.equal(torrent.magnetURI, common.numbers.magnetURI)
+ t.equal(torrent.infoHash, fixtures.numbers.parsedTorrent.infoHash)
+ t.equal(torrent.magnetURI, fixtures.numbers.magnetURI)
client.remove(torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
diff --git a/test/node/blocklist-dht.js b/test/node/blocklist-dht.js
index 474d5c3..3e23424 100644
--- a/test/node/blocklist-dht.js
+++ b/test/node/blocklist-dht.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var DHT = require('bittorrent-dht/server')
+var fixtures = require('webtorrent-fixtures')
var series = require('run-series')
var test = require('tape')
var WebTorrent = require('../../')
@@ -25,7 +25,7 @@ test('blocklist blocks peers discovered via DHT', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })
- var torrent1 = client1.add(common.leaves.parsedTorrent)
+ var torrent1 = client1.add(fixtures.leaves.parsedTorrent)
torrent1.on('peer', function () {
t.fail('client1 should not find any peers')
@@ -63,7 +63,7 @@ test('blocklist blocks peers discovered via DHT', function (t) {
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })
- var torrent2 = client2.add(common.leaves.parsedTorrent)
+ var torrent2 = client2.add(fixtures.leaves.parsedTorrent)
torrent2.on('blockedPeer', function (addr) {
t.pass('client2 blocked connection to client1: ' + addr)
diff --git a/test/node/blocklist-tracker.js b/test/node/blocklist-tracker.js
index cac9468..88fbf41 100644
--- a/test/node/blocklist-tracker.js
+++ b/test/node/blocklist-tracker.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var extend = require('xtend')
+var fixtures = require('webtorrent-fixtures')
var series = require('run-series')
var test = require('tape')
var TrackerServer = require('bittorrent-tracker/server')
@@ -8,7 +8,7 @@ var WebTorrent = require('../../')
test('blocklist blocks peers discovered via tracker', function (t) {
t.plan(9)
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.leaves.parsedTorrent)
var tracker, client1, client2
series([
diff --git a/test/node/blocklist.js b/test/node/blocklist.js
index 8a7ee9c..d67af91 100644
--- a/test/node/blocklist.js
+++ b/test/node/blocklist.js
@@ -1,14 +1,10 @@
-var common = require('../common')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var http = require('http')
-var path = require('path')
var test = require('tape')
var WebTorrent = require('../../')
var zlib = require('zlib')
-var blocklistPath = path.resolve(__dirname, '..', 'fixtures', 'blocklist.txt')
-var blocklistGzipPath = path.resolve(__dirname, '..', 'fixtures', 'blocklist.txt.gz')
-
function assertBlocked (t, torrent, addr) {
torrent.once('blockedPeer', function (_addr) {
t.equal(addr, _addr)
@@ -36,7 +32,7 @@ test('blocklist (single IP)', function (t) {
// blocklist isn't fully loaded until `ready` event
client.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertBlocked(t, torrent, '1.2.3.4:1234')
assertBlocked(t, torrent, '1.2.3.4:6969')
assertReachable(t, torrent, '1.1.1.1:1234')
@@ -60,7 +56,7 @@ test('blocklist (array of IPs)', function (t) {
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertBlocked(t, torrent, '1.2.3.4:1234')
assertBlocked(t, torrent, '1.2.3.4:6969')
assertBlocked(t, torrent, '5.6.7.8:1234')
@@ -127,7 +123,7 @@ test('blocklist (array of IP ranges)', function (t) {
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertList(t, torrent)
client.destroy(function (err) {
t.error(err, 'client destroyed')
@@ -142,7 +138,7 @@ test('blocklist (http url)', function (t) {
// Check that WebTorrent declares a user agent
t.ok(req.headers['user-agent'].indexOf('WebTorrent') !== -1)
- fs.createReadStream(blocklistPath).pipe(res)
+ fs.createReadStream(fixtures.blocklist.path).pipe(res)
})
server.listen(0, function () {
@@ -156,7 +152,7 @@ test('blocklist (http url)', function (t) {
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertList(t, torrent)
client.destroy(function (err) {
t.error(err, 'client destroyed')
@@ -176,7 +172,7 @@ test('blocklist (http url with gzip encoding)', function (t) {
t.ok(req.headers['user-agent'].indexOf('WebTorrent') !== -1)
res.setHeader('content-encoding', 'gzip')
- fs.createReadStream(blocklistPath)
+ fs.createReadStream(fixtures.blocklist.path)
.pipe(zlib.createGzip())
.pipe(res)
})
@@ -192,7 +188,7 @@ test('blocklist (http url with gzip encoding)', function (t) {
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertList(t, torrent)
client.destroy(function (err) {
t.error(err, 'client destroyed')
@@ -212,7 +208,7 @@ test('blocklist (http url with deflate encoding)', function (t) {
t.ok(req.headers['user-agent'].indexOf('WebTorrent') !== -1)
res.setHeader('content-encoding', 'deflate')
- fs.createReadStream(blocklistPath)
+ fs.createReadStream(fixtures.blocklist.path)
.pipe(zlib.createDeflate())
.pipe(res)
})
@@ -228,7 +224,7 @@ test('blocklist (http url with deflate encoding)', function (t) {
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertList(t, torrent)
client.destroy(function (err) {
t.error(err, 'client destroyed')
@@ -246,12 +242,12 @@ test('blocklist (fs path)', function (t) {
var client = new WebTorrent({
dht: false,
tracker: false,
- blocklist: blocklistPath
+ blocklist: fixtures.blocklist.path
})
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertList(t, torrent)
client.destroy(function (err) {
t.error(err, 'client destroyed')
@@ -265,12 +261,12 @@ test('blocklist (fs path with gzip)', function (t) {
var client = new WebTorrent({
dht: false,
tracker: false,
- blocklist: blocklistGzipPath
+ blocklist: fixtures.blocklist.gzipPath
})
.on('error', function (err) { t.fail(err) })
.on('warning', function (err) { t.fail(err) })
.on('ready', function () {
- client.add(common.leaves.parsedTorrent, function (torrent) {
+ client.add(fixtures.leaves.parsedTorrent, function (torrent) {
assertList(t, torrent)
client.destroy(function (err) {
t.error(err, 'client destroyed')
diff --git a/test/node/cmd.js b/test/node/cmd.js
index 4c4f9e2..d31824f 100644
--- a/test/node/cmd.js
+++ b/test/node/cmd.js
@@ -1,6 +1,6 @@
-var common = require('../common')
var cp = require('child_process')
var extend = require('xtend')
+var fixtures = require('webtorrent-fixtures')
var parseTorrent = require('parse-torrent')
var path = require('path')
var spawn = require('cross-spawn-async')
@@ -51,10 +51,10 @@ test('Command line: webtorrent version', function (t) {
test('Command line: webtorrent info /path/to/file.torrent', function (t) {
t.plan(3)
- cp.exec(CMD + ' info ' + common.leaves.torrentPath, function (err, data) {
+ cp.exec(CMD + ' info ' + fixtures.leaves.torrentPath, function (err, data) {
t.error(err)
data = JSON.parse(data)
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.leaves.parsedTorrent)
delete parsedTorrent.info
delete parsedTorrent.infoBuffer
delete parsedTorrent.infoHashBuffer
@@ -83,7 +83,7 @@ test('Command line: webtorrent info magnet_uri', function (t) {
test('Command line: webtorrent create /path/to/file', function (t) {
t.plan(1)
- var child = spawn('node', [ CMD_PATH, 'create', common.leaves.contentPath ])
+ var child = spawn('node', [ CMD_PATH, 'create', fixtures.leaves.contentPath ])
child.on('error', function (err) { t.fail(err) })
var chunks = []
@@ -100,7 +100,9 @@ test('Command line: webtorrent create /path/to/file', function (t) {
test('Command line: webtorrent download <torrent file> (with local content)', function (t) {
t.plan(2)
- cp.exec(CMD + ' download ' + common.leaves.torrentPath + ' --out test/fixtures', function (err, data) {
+ var fixturesPath = path.join(path.dirname(require.resolve('webtorrent-fixtures')), 'fixtures')
+
+ cp.exec(CMD + ' download ' + fixtures.leaves.torrentPath + ' --out ' + fixturesPath, function (err, data) {
t.error(err)
t.ok(data.indexOf('successfully') !== -1)
})
diff --git a/test/node/download-dht-magnet.js b/test/node/download-dht-magnet.js
index 9ddba86..028d6a6 100644
--- a/test/node/download-dht-magnet.js
+++ b/test/node/download-dht-magnet.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var DHT = require('bittorrent-dht/server')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var networkAddress = require('network-address')
var series = require('run-series')
@@ -30,7 +30,7 @@ test('Download using DHT (via magnet uri)', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })
- var torrent = client1.add(common.leaves.parsedTorrent)
+ var torrent = client1.add(fixtures.leaves.parsedTorrent)
torrent.on('dhtAnnounce', function () {
t.pass('finished dht announce')
@@ -46,7 +46,7 @@ test('Download using DHT (via magnet uri)', function (t) {
t.deepEqual(torrent.files.map(function (file) { return file.name }), names)
})
- torrent.load(fs.createReadStream(common.leaves.contentPath), function (err) {
+ torrent.load(fs.createReadStream(fixtures.leaves.contentPath), function (err) {
t.error(err)
loaded = true
maybeDone()
@@ -71,7 +71,7 @@ test('Download using DHT (via magnet uri)', function (t) {
client2.on('torrent', function (torrent) {
torrent.files[0].getBuffer(function (err, buf) {
t.error(err)
- t.deepEqual(buf, common.leaves.content, 'downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
maybeDone()
@@ -85,7 +85,7 @@ test('Download using DHT (via magnet uri)', function (t) {
})
})
- client2.add(common.leaves.magnetURI)
+ client2.add(fixtures.leaves.magnetURI)
var gotBuffer = false
var gotDone = false
diff --git a/test/node/download-dht-torrent.js b/test/node/download-dht-torrent.js
index b6262c3..5f88da5 100644
--- a/test/node/download-dht-torrent.js
+++ b/test/node/download-dht-torrent.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var DHT = require('bittorrent-dht/server')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var series = require('run-series')
var test = require('tape')
@@ -29,7 +29,7 @@ test('Download using DHT (via .torrent file)', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })
- var torrent = client1.add(common.leaves.parsedTorrent)
+ var torrent = client1.add(fixtures.leaves.parsedTorrent)
torrent.on('ready', function () {
// torrent metadata has been fetched -- sanity check it
@@ -39,7 +39,7 @@ test('Download using DHT (via .torrent file)', function (t) {
t.deepEqual(torrent.files.map(function (file) { return file.name }), names)
})
- torrent.load(fs.createReadStream(common.leaves.contentPath), function (err) {
+ torrent.load(fs.createReadStream(fixtures.leaves.contentPath), function (err) {
loaded = true
maybeDone(err)
})
@@ -69,7 +69,7 @@ test('Download using DHT (via .torrent file)', function (t) {
torrent.files.forEach(function (file) {
file.getBuffer(function (err, buf) {
if (err) throw err
- t.deepEqual(buf, common.leaves.content, 'downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
maybeDone()
})
@@ -88,7 +88,7 @@ test('Download using DHT (via .torrent file)', function (t) {
}
})
- client2.add(common.leaves.parsedTorrent)
+ client2.add(fixtures.leaves.parsedTorrent)
}
], function (err) {
t.error(err)
diff --git a/test/node/download-private-dht.js b/test/node/download-private-dht.js
index ee5125e..023f7ff 100644
--- a/test/node/download-private-dht.js
+++ b/test/node/download-private-dht.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var DHT = require('bittorrent-dht/server')
+var fixtures = require('webtorrent-fixtures')
var series = require('run-series')
var test = require('tape')
var WebTorrent = require('../../')
@@ -28,7 +28,7 @@ test('private torrent should not use DHT', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.bunny.parsedTorrent)
+ var torrent = client.add(fixtures.bunny.parsedTorrent)
torrent.on('dhtAnnounce', function () {
t.fail('client announced to dht')
@@ -76,7 +76,7 @@ test('public torrent should use DHT', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- var torrent = client.add(common.leaves.parsedTorrent)
+ var torrent = client.add(fixtures.leaves.parsedTorrent)
torrent.on('dhtAnnounce', function () {
t.pass('client announced to dht')
diff --git a/test/node/download-tracker-magnet.js b/test/node/download-tracker-magnet.js
index 12607e7..a310350 100644
--- a/test/node/download-tracker-magnet.js
+++ b/test/node/download-tracker-magnet.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var extend = require('xtend')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var series = require('run-series')
var test = require('tape')
@@ -29,7 +29,7 @@ function magnetDownloadTest (t, serverType) {
trackerStartCount += 1
})
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.leaves.parsedTorrent)
var magnetURI, client1, client2
series([
@@ -61,7 +61,7 @@ function magnetDownloadTest (t, serverType) {
t.deepEqual(torrent.files.map(function (file) { return file.name }), names)
- torrent.load(fs.createReadStream(common.leaves.contentPath), function (err) {
+ torrent.load(fs.createReadStream(fixtures.leaves.contentPath), function (err) {
cb(err)
})
})
@@ -79,7 +79,7 @@ function magnetDownloadTest (t, serverType) {
torrent.files.forEach(function (file) {
file.getBuffer(function (err, buf) {
if (err) throw err
- t.deepEqual(buf, common.leaves.content, 'downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
maybeDone()
})
diff --git a/test/node/download-tracker-torrent.js b/test/node/download-tracker-torrent.js
index 5949a39..c9068c5 100644
--- a/test/node/download-tracker-torrent.js
+++ b/test/node/download-tracker-torrent.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var extend = require('xtend')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var series = require('run-series')
var test = require('tape')
@@ -18,7 +18,7 @@ function torrentDownloadTest (t, serverType) {
t.plan(9)
var trackerStartCount = 0
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.leaves.parsedTorrent)
var tracker = new TrackerServer(
serverType === 'udp' ? { http: false, ws: false } : { udp: false, ws: false }
@@ -62,7 +62,7 @@ function torrentDownloadTest (t, serverType) {
t.deepEqual(torrent.files.map(function (file) { return file.name }), names)
- torrent.load(fs.createReadStream(common.leaves.contentPath), cb)
+ torrent.load(fs.createReadStream(fixtures.leaves.contentPath), cb)
})
client1.add(parsedTorrent)
@@ -79,7 +79,7 @@ function torrentDownloadTest (t, serverType) {
torrent.files.forEach(function (file) {
file.getBuffer(function (err, buf) {
if (err) throw err
- t.deepEqual(buf, common.leaves.content, 'downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
maybeDone()
})
diff --git a/test/node/download-webseed-magnet.js b/test/node/download-webseed-magnet.js
index b963446..47a10f6 100644
--- a/test/node/download-webseed-magnet.js
+++ b/test/node/download-webseed-magnet.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var finalhandler = require('finalhandler')
+var fixtures = require('webtorrent-fixtures')
var http = require('http')
var path = require('path')
var series = require('run-series')
@@ -56,7 +56,7 @@ test('Download using webseed (via magnet uri)', function (t) {
maybeDone()
})
- client1.add(common.leaves.parsedTorrent)
+ client1.add(fixtures.leaves.parsedTorrent)
},
function (cb) {
@@ -65,14 +65,14 @@ test('Download using webseed (via magnet uri)', function (t) {
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })
- var webSeedUrl = 'http://localhost:' + httpServer.address().port + '/' + common.leaves.parsedTorrent.name
- var magnetURI = common.leaves.magnetURI + '&ws=' + encodeURIComponent(webSeedUrl)
+ var webSeedUrl = 'http://localhost:' + httpServer.address().port + '/' + fixtures.leaves.parsedTorrent.name
+ var magnetURI = fixtures.leaves.magnetURI + '&ws=' + encodeURIComponent(webSeedUrl)
client2.on('torrent', function (torrent) {
torrent.files.forEach(function (file) {
file.getBuffer(function (err, buf) {
t.error(err)
- t.deepEqual(buf, common.leaves.content, 'downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
maybeDone()
})
diff --git a/test/node/download-webseed-torrent.js b/test/node/download-webseed-torrent.js
index d10eeee..e80ae05 100644
--- a/test/node/download-webseed-torrent.js
+++ b/test/node/download-webseed-torrent.js
@@ -1,6 +1,6 @@
-var common = require('../common')
var extend = require('xtend')
var finalhandler = require('finalhandler')
+var fixtures = require('webtorrent-fixtures')
var http = require('http')
var path = require('path')
var series = require('run-series')
@@ -11,7 +11,7 @@ var WebTorrent = require('../../')
test('Download using webseed (via .torrent file)', function (t) {
t.plan(6)
- var parsedTorrent = extend(common.leaves.parsedTorrent)
+ var parsedTorrent = extend(fixtures.leaves.parsedTorrent)
var httpServer = http.createServer(function (req, res) {
var done = finalhandler(req, res)
@@ -28,7 +28,7 @@ test('Download using webseed (via .torrent file)', function (t) {
function (cb) {
parsedTorrent.urlList = [
- 'http://localhost:' + httpServer.address().port + '/' + common.leaves.parsedTorrent.name
+ 'http://localhost:' + httpServer.address().port + '/' + fixtures.leaves.parsedTorrent.name
]
client = new WebTorrent({ dht: false, tracker: false })
@@ -40,7 +40,7 @@ test('Download using webseed (via .torrent file)', function (t) {
torrent.files.forEach(function (file) {
file.getBuffer(function (err, buf) {
t.error(err)
- t.deepEqual(buf, common.leaves.content, 'downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'downloaded correct content')
gotBuffer = true
maybeDone()
})
diff --git a/test/node/duplicates.js b/test/node/duplicates.js
index 0421546..8689b85 100644
--- a/test/node/duplicates.js
+++ b/test/node/duplicates.js
@@ -1,4 +1,4 @@
-var common = require('../common')
+var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../../')
@@ -9,7 +9,7 @@ test('client.seed followed by duplicate client.add', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(common.leaves.content, {
+ client.seed(fixtures.leaves.content, {
name: 'Leaves of Grass by Walt Whitman.epub'
}, function (torrent1) {
t.equal(client.torrents.length, 1)
@@ -33,7 +33,7 @@ test('client.seed followed by two duplicate client.add calls', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(common.leaves.content, {
+ client.seed(fixtures.leaves.content, {
name: 'Leaves of Grass by Walt Whitman.epub'
}, function (torrent1) {
t.equal(client.torrents.length, 1)
@@ -62,7 +62,7 @@ test('successive sync client.add, client.remove, client.add, client.remove', fun
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.seed(common.leaves.content, {
+ client.seed(fixtures.leaves.content, {
name: 'Leaves of Grass by Walt Whitman.epub'
}, function (torrent1) {
t.equal(client.torrents.length, 1)
diff --git a/test/node/extensions.js b/test/node/extensions.js
index 399c1e3..5b68950 100644
--- a/test/node/extensions.js
+++ b/test/node/extensions.js
@@ -1,4 +1,4 @@
-var common = require('../common')
+var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../../')
@@ -39,12 +39,12 @@ test('extension support', function (t) {
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })
- client1.add(common.leaves.parsedTorrent, function (torrent1) {
+ client1.add(fixtures.leaves.parsedTorrent, function (torrent1) {
torrent1.on('wire', function (wire) {
t.pass('client1 onWire')
wire.use(Extension)
})
- var torrent2 = client2.add(common.leaves.parsedTorrent.infoHash)
+ var torrent2 = client2.add(fixtures.leaves.parsedTorrent.infoHash)
torrent2.on('wire', function (wire) {
t.pass('client2 onWire')
wire.use(Extension)
diff --git a/test/node/metadata.js b/test/node/metadata.js
index a6d082d..6a40f25 100644
--- a/test/node/metadata.js
+++ b/test/node/metadata.js
@@ -1,4 +1,4 @@
-var common = require('../common')
+var fixtures = require('webtorrent-fixtures')
var test = require('tape')
var WebTorrent = require('../../')
@@ -20,13 +20,13 @@ test('ut_metadata transfer', function (t) {
})
// client1 starts with metadata from torrent file
- client1.add(common.leaves.torrent)
+ client1.add(fixtures.leaves.torrent)
client1.on('torrent', function (torrent1) {
- t.deepEqual(torrent1.info, common.leaves.parsedTorrent.info)
+ t.deepEqual(torrent1.info, fixtures.leaves.parsedTorrent.info)
// client2 starts with infohash
- client2.add(common.leaves.parsedTorrent.infoHash)
+ client2.add(fixtures.leaves.parsedTorrent.infoHash)
client2.on('listening', function (port, torrent2) {
// manually add the peer
diff --git a/test/node/seed-stream.js b/test/node/seed-stream.js
index b7da799..eafc9e7 100644
--- a/test/node/seed-stream.js
+++ b/test/node/seed-stream.js
@@ -1,8 +1,8 @@
-var test = require('tape')
var Readable = require('readable-stream').Readable
+var series = require('run-series')
+var test = require('tape')
var Tracker = require('bittorrent-tracker/server')
var WebTorrent = require('../../')
-var series = require('run-series')
test('client.seed: stream', function (t) {
t.plan(9)
diff --git a/test/node/seed-while-download.js b/test/node/seed-while-download.js
index 4b34e98..8cb32e4 100644
--- a/test/node/seed-while-download.js
+++ b/test/node/seed-while-download.js
@@ -1,5 +1,5 @@
-var common = require('../common')
var DHT = require('bittorrent-dht/server')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var series = require('run-series')
var test = require('tape')
@@ -29,7 +29,7 @@ test('Seed and download a file at the same time', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })
- var torrent = client1.add(common.leaves.torrent)
+ var torrent = client1.add(fixtures.leaves.torrent)
torrent.on('dhtAnnounce', function () {
t.pass('client1 finished dht announce')
@@ -37,7 +37,7 @@ test('Seed and download a file at the same time', function (t) {
maybeDone()
})
- torrent.load(fs.createReadStream(common.leaves.contentPath), function (err) {
+ torrent.load(fs.createReadStream(fixtures.leaves.contentPath), function (err) {
t.error(err, 'client1 started seeding')
loaded = true
maybeDone()
@@ -60,7 +60,7 @@ test('Seed and download a file at the same time', function (t) {
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })
- var torrent = client2.add(common.alice.torrent)
+ var torrent = client2.add(fixtures.alice.torrent)
torrent.on('dhtAnnounce', function () {
t.pass('client2 finished dht announce')
@@ -68,7 +68,7 @@ test('Seed and download a file at the same time', function (t) {
maybeDone()
})
- torrent.load(fs.createReadStream(common.alice.contentPath), function (err) {
+ torrent.load(fs.createReadStream(fixtures.alice.contentPath), function (err) {
t.error(err, 'client2 started seeding')
loaded = true
maybeDone()
@@ -82,12 +82,12 @@ test('Seed and download a file at the same time', function (t) {
},
function (cb) {
- client1.add(common.alice.magnetURI)
+ client1.add(fixtures.alice.magnetURI)
client1.on('torrent', function (torrent) {
torrent.files[0].getBuffer(function (err, buf) {
t.error(err)
- t.deepEqual(buf, common.alice.content, 'client1 downloaded correct content')
+ t.deepEqual(buf, fixtures.alice.content, 'client1 downloaded correct content')
gotBuffer1 = true
maybeDone()
})
@@ -99,12 +99,12 @@ test('Seed and download a file at the same time', function (t) {
})
})
- client2.add(common.leaves.magnetURI)
+ client2.add(fixtures.leaves.magnetURI)
client2.on('torrent', function (torrent) {
torrent.files[0].getBuffer(function (err, buf) {
t.error(err)
- t.deepEqual(buf, common.leaves.content, 'client2 downloaded correct content')
+ t.deepEqual(buf, fixtures.leaves.content, 'client2 downloaded correct content')
gotBuffer2 = true
maybeDone()
})
diff --git a/test/node/server.js b/test/node/server.js
index 62565b3..564d7b1 100644
--- a/test/node/server.js
+++ b/test/node/server.js
@@ -1,4 +1,4 @@
-var common = require('../common')
+var fixtures = require('webtorrent-fixtures')
var fs = require('fs')
var get = require('simple-get')
var test = require('tape')
@@ -12,7 +12,7 @@ test('torrent.createServer: programmatic http server', function (t) {
client.on('error', function (err) { t.fail(err) })
client.on('warning', function (err) { t.fail(err) })
- client.add(common.leaves.torrent, function (torrent) {
+ client.add(fixtures.leaves.torrent, function (torrent) {
t.pass('got "torrent" event')
var server = torrent.createServer()
@@ -21,7 +21,7 @@ test('torrent.createServer: programmatic http server', function (t) {
t.pass('server is listening on ' + port)
// Seeding after server is created should work
- torrent.load(fs.createReadStream(common.leaves.contentPath), function (err) {
+ torrent.load(fs.createReadStream(fixtures.leaves.contentPath), function (err) {
t.error(err, 'loaded seed content into torrent')
})
@@ -36,7 +36,7 @@ test('torrent.createServer: programmatic http server', function (t) {
// Verify file content for first (and only) file
get.concat(host + '/0', function (err, res, data) {
t.error(err, 'got http response for /0')
- t.deepEqual(data, common.leaves.content)
+ t.deepEqual(data, fixtures.leaves.content)
server.close(function () {
t.pass('server closed')