diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-06-11 07:00:42 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-06-11 07:00:42 +0300 |
commit | cc20e47f27798028c533965ea160a3b42e6999ca (patch) | |
tree | ecb1d90a846ddd375dbaa9aed8a1c4db4d85df28 /test | |
parent | e677499e46d3b905f54464ded98c832faaeaad37 (diff) |
add failing test for #348
Diffstat (limited to 'test')
-rw-r--r-- | test/duplicates.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/duplicates.js b/test/duplicates.js new file mode 100644 index 0000000..f1585a8 --- /dev/null +++ b/test/duplicates.js @@ -0,0 +1,48 @@ +var fs = require('fs') +var test = require('tape') +var WebTorrent = require('../') + +var leavesBook = fs.readFileSync(__dirname + '/content/Leaves of Grass by Walt Whitman.epub') + +test('client.seed followed by duplicate client.add', function (t) { + t.plan(3) + + var opts = { + name: 'Leaves of Grass by Walt Whitman.epub' + } + + var client = new WebTorrent({ dht: false, tracker: false }) + client.seed(leavesBook, opts, function (torrent1) { + client.add(torrent1.infoHash, function (torrent2) { + t.equal(torrent1.infoHash, torrent2.infoHash) + t.equal(client.torrents.length, 1) + client.destroy(function () { + t.pass('destroyed client') + }) + }) + }) +}) + +test('client.seed followed by duplicate client.add, twice', function (t) { + t.plan(5) + + var opts = { + name: 'Leaves of Grass by Walt Whitman.epub' + } + + var client = new WebTorrent({ dht: false, tracker: false }) + + client.seed(leavesBook, opts, function (torrent1) { + client.add(torrent1.infoHash, function (torrent2) { + t.equal(torrent1.infoHash, torrent2.infoHash) + t.equal(client.torrents.length, 1) + client.add(torrent1.infoHash, function (torrent2) { + t.equal(torrent1.infoHash, torrent2.infoHash) + t.equal(client.torrents.length, 1) + client.destroy(function () { + t.pass('destroyed client') + }) + }) + }) + }) +}) |