diff options
Diffstat (limited to 'test/node/download-private-dht.js')
-rw-r--r-- | test/node/download-private-dht.js | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/test/node/download-private-dht.js b/test/node/download-private-dht.js index 036c889..04a2c7d 100644 --- a/test/node/download-private-dht.js +++ b/test/node/download-private-dht.js @@ -5,207 +5,207 @@ const series = require('run-series') const test = require('tape') const WebTorrent = require('../../') -test('private torrent should not use DHT', function (t) { +test('private torrent should not use DHT', t => { t.plan(4) const dhtServer = new DHT({ bootstrap: false }) - dhtServer.on('error', function (err) { t.fail(err) }) - dhtServer.on('warning', function (err) { t.fail(err) }) + dhtServer.on('error', err => { t.fail(err) }) + dhtServer.on('warning', err => { t.fail(err) }) let client series([ - function (cb) { + cb => { dhtServer.listen(cb) }, - function (cb) { + cb => { client = new WebTorrent({ tracker: false, lsd: false, - dht: { bootstrap: '127.0.0.1:' + dhtServer.address().port } + dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` } }) - client.on('error', function (err) { t.fail(err) }) - client.on('warning', function (err) { t.fail(err) }) + client.on('error', err => { t.fail(err) }) + client.on('warning', err => { t.fail(err) }) const torrent = client.add(fixtures.bunny.parsedTorrent, { store: MemoryChunkStore }) - torrent.on('dhtAnnounce', function () { + torrent.on('dhtAnnounce', () => { t.fail('client announced to dht') }) - client.on('torrent', function () { + client.on('torrent', () => { if (!torrent.discovery.dht) { t.pass('dht is disabled for this torrent') cb(null) } }) } - ], function (err) { + ], err => { t.error(err) - dhtServer.destroy(function (err) { + dhtServer.destroy(err => { t.error(err, 'dht server destroyed') }) - client.destroy(function (err) { + client.destroy(err => { t.error(err, 'client destroyed') }) }) }) -test('public torrent should use DHT', function (t) { +test('public torrent should use DHT', t => { t.plan(4) const dhtServer = new DHT({ bootstrap: false }) - dhtServer.on('error', function (err) { t.fail(err) }) - dhtServer.on('warning', function (err) { t.fail(err) }) + dhtServer.on('error', err => { t.fail(err) }) + dhtServer.on('warning', err => { t.fail(err) }) let client series([ - function (cb) { + cb => { dhtServer.listen(cb) }, - function (cb) { + cb => { client = new WebTorrent({ tracker: false, lsd: false, - dht: { bootstrap: '127.0.0.1:' + dhtServer.address().port } + dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` } }) - client.on('error', function (err) { t.fail(err) }) - client.on('warning', function (err) { t.fail(err) }) + client.on('error', err => { t.fail(err) }) + client.on('warning', err => { t.fail(err) }) const torrent = client.add(fixtures.leaves.parsedTorrent, { store: MemoryChunkStore }) - torrent.on('dhtAnnounce', function () { + torrent.on('dhtAnnounce', () => { t.pass('client announced to dht') cb(null) }) - client.on('torrent', function () { + client.on('torrent', () => { if (!torrent.client.dht) { t.fail('dht server is null') } }) } - ], function (err) { + ], err => { t.error(err) - dhtServer.destroy(function (err) { + dhtServer.destroy(err => { t.error(err, 'dht server destroyed') }) - client.destroy(function (err) { + client.destroy(err => { t.error(err, 'client destroyed') }) }) }) -test('public torrent with forced private option should not use DHT', function (t) { +test('public torrent with forced private option should not use DHT', t => { t.plan(4) const dhtServer = new DHT({ bootstrap: false }) - dhtServer.on('error', function (err) { t.fail(err) }) - dhtServer.on('warning', function (err) { t.fail(err) }) + dhtServer.on('error', err => { t.fail(err) }) + dhtServer.on('warning', err => { t.fail(err) }) let client series([ - function (cb) { + cb => { dhtServer.listen(cb) }, - function (cb) { + cb => { client = new WebTorrent({ tracker: false, lsd: false, - dht: { bootstrap: '127.0.0.1:' + dhtServer.address().port } + dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` } }) - client.on('error', function (err) { t.fail(err) }) - client.on('warning', function (err) { t.fail(err) }) + client.on('error', err => { t.fail(err) }) + client.on('warning', err => { t.fail(err) }) const torrent = client.add(fixtures.leaves.parsedTorrent, { private: true, store: MemoryChunkStore }) - torrent.on('dhtAnnounce', function () { + torrent.on('dhtAnnounce', () => { t.fail('client announced to dht') }) - client.on('torrent', function () { + client.on('torrent', () => { if (!torrent.discovery.dht) { t.pass('dht is disabled for this torrent') cb(null) } }) } - ], function (err) { + ], err => { t.error(err) - dhtServer.destroy(function (err) { + dhtServer.destroy(err => { t.error(err, 'dht server destroyed') }) - client.destroy(function (err) { + client.destroy(err => { t.error(err, 'client destroyed') }) }) }) -test('private torrent with forced public option should use DHT', function (t) { +test('private torrent with forced public option should use DHT', t => { t.plan(4) const dhtServer = new DHT({ bootstrap: false }) - dhtServer.on('error', function (err) { t.fail(err) }) - dhtServer.on('warning', function (err) { t.fail(err) }) + dhtServer.on('error', err => { t.fail(err) }) + dhtServer.on('warning', err => { t.fail(err) }) let client series([ - function (cb) { + cb => { dhtServer.listen(cb) }, - function (cb) { + cb => { client = new WebTorrent({ tracker: false, lsd: false, - dht: { bootstrap: '127.0.0.1:' + dhtServer.address().port } + dht: { bootstrap: `127.0.0.1:${dhtServer.address().port}` } }) - client.on('error', function (err) { t.fail(err) }) - client.on('warning', function (err) { t.fail(err) }) + client.on('error', err => { t.fail(err) }) + client.on('warning', err => { t.fail(err) }) const torrent = client.add(fixtures.bunny.parsedTorrent, { private: false, store: MemoryChunkStore }) - torrent.on('dhtAnnounce', function () { + torrent.on('dhtAnnounce', () => { t.pass('client announced to dht') cb(null) }) - client.on('torrent', function () { + client.on('torrent', () => { if (!torrent.client.dht) { t.fail('dht server is null') } }) } - ], function (err) { + ], err => { t.error(err) - dhtServer.destroy(function (err) { + dhtServer.destroy(err => { t.error(err, 'dht server destroyed') }) - client.destroy(function (err) { + client.destroy(err => { t.error(err, 'client destroyed') }) }) |