diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-01-04 01:11:41 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-01-04 01:11:41 +0300 |
commit | 751702df9564980bb8a2b8cd8334a43c56b010f1 (patch) | |
tree | dee84afcc7d875f860f52a10f593969a47bca2e4 /test/blocklist.js | |
parent | fcf1912c93c1d2d53a489323ac15e6babd566875 (diff) |
Add test: blocklist blocks peers discovered via DHT
For #87
Diffstat (limited to 'test/blocklist.js')
-rw-r--r-- | test/blocklist.js | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/test/blocklist.js b/test/blocklist.js deleted file mode 100644 index 1c7199d..0000000 --- a/test/blocklist.js +++ /dev/null @@ -1,76 +0,0 @@ -var auto = require('run-auto') -var fs = require('fs') -var parseTorrent = require('parse-torrent') -var test = require('tape') -var TrackerServer = require('bittorrent-tracker/server') -var WebTorrent = require('../') - -var leavesTorrent = fs.readFileSync(__dirname + '/torrents/leaves.torrent') -var leavesParsed = parseTorrent(leavesTorrent) - -// TODO: test blocklist blocking messages to DHT nodes -// TODO: test all ways to specify blocklists - -test('blocklist blocks connections to peers', function (t) { - t.plan(8) - - auto({ - tracker: function (cb) { - var tracker = new TrackerServer({ udp: false }) - - tracker.listen(function (port) { - var announceUrl = 'http://127.0.0.1:' + port + '/announce' - - // Overwrite announce with our local tracker - leavesParsed.announce = [ announceUrl ] - leavesParsed.announceList = [[ announceUrl ]] - - cb(null, tracker) - }) - - tracker.on('start', function () { - t.pass('client connected to tracker') // 2x, once for each client - }) - }, - - client1: ['tracker', function (cb) { - var client1 = new WebTorrent({ dht: false }) - client1.on('error', function (err) { t.fail(err) }) - - var torrent1 = client1.add(leavesParsed) - - torrent1.on('peer', function () { - t.pass('client1 found itself') - cb(null, client1) - }) - }], - - client2: ['client1', function (cb) { - var client2 = new WebTorrent({ - dht: false, - blocklist: [ '127.0.0.1' ] - }) - client2.on('error', function (err) { t.fail(err) }) - - var torrent2 = client2.add(leavesParsed) - - torrent2.on('blocked-peer', function () { - t.pass('client2 blocked connection to client1 and client2') - cb(null, client2) - }) - }] - - }, function (err, r) { - if (err) throw err - - r.tracker.close(function () { - t.pass('tracker closed') - }) - r.client1.destroy(function () { - t.pass('client1 destroyed') - }) - r.client2.destroy(function () { - t.pass('client2 destroyed') - }) - }) -}) |