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
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2014-09-21 05:41:24 +0400
committerFeross Aboukhadijeh <feross@feross.org>2014-09-21 05:41:24 +0400
commit93686505fbc90522c75b6c151ec7261aa76098de (patch)
tree5b474b920e79b7b39b6804fac5e6a641de6ae843 /test/multiple.js
parent2e14192c311f64c20496a72af7ffce36495be92b (diff)
merge `bittorrent-client` into this module
When I started the WebTorrent project I thought there were going to need to be two separate client implementations (bittorrent-client and webtorrent-client) that would get tied together in a higher-level module. Fortunately, this was not necessary because of the awesome “browser” field support in browserify. By substituting just a few modules, we can make the same module (webtorrent) work in node AND the browser, with the same codebase! So, from now on, you can just `require(‘webtorrent’)` in node or the browser, and it will just work. You can also `npm install webtorrent` if you want to use bittorrent in a node app or script. Lastly, you can `npm install webtorrent -g` if you want to use webtorrent as a command line app (it installs a `webtorrent` command).
Diffstat (limited to 'test/multiple.js')
-rw-r--r--test/multiple.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/multiple.js b/test/multiple.js
new file mode 100644
index 0000000..cf92266
--- /dev/null
+++ b/test/multiple.js
@@ -0,0 +1,60 @@
+/*
+var BitTorrentClient = 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 BitTorrentClient({ 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 BitTorrentClient()
+ 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()
+ }
+ })
+ })
+})
+*/