diff options
author | Diego RodrÃguez Baquero <github@diegorbaquero.com> | 2021-07-11 04:27:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 04:27:48 +0300 |
commit | 46033ae52eca6e22301bb8ed9566c498d3494711 (patch) | |
tree | 93cf4583fc9471dbe8e0b050c55b643638768f40 /test/node/seed-stream.js | |
parent | feb719d5426df7ad45d00ffadecb931780763134 (diff) |
fix: modernize code (#2134)
* fix: modernize code
* standard fix
Diffstat (limited to 'test/node/seed-stream.js')
-rw-r--r-- | test/node/seed-stream.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/test/node/seed-stream.js b/test/node/seed-stream.js index fda91d7..0e0db73 100644 --- a/test/node/seed-stream.js +++ b/test/node/seed-stream.js @@ -4,32 +4,32 @@ const test = require('tape') const Tracker = require('bittorrent-tracker/server') const WebTorrent = require('../../') -test('client.seed: stream', function (t) { +test('client.seed: stream', t => { t.plan(9) const tracker = new Tracker({ udp: false, ws: false }) - tracker.on('error', function (err) { t.fail(err) }) - tracker.on('warning', function (err) { t.fail(err) }) + tracker.on('error', err => { t.fail(err) }) + tracker.on('warning', err => { t.fail(err) }) let seeder, client, announceUrl, magnetURI series([ - function (cb) { + cb => { tracker.listen(cb) }, - function (cb) { + cb => { const port = tracker.http.address().port - announceUrl = 'http://localhost:' + port + '/announce' + announceUrl = `http://localhost:${port}/announce` seeder = new WebTorrent({ dht: false, lsd: false }) - seeder.on('error', function (err) { t.fail(err) }) - seeder.on('warning', function (err) { t.fail(err) }) + seeder.on('error', err => { t.fail(err) }) + seeder.on('warning', err => { t.fail(err) }) const stream = new Readable() - stream._read = function () {} + stream._read = () => {} stream.push('HELLO WORLD\n') stream.push(null) @@ -38,23 +38,23 @@ test('client.seed: stream', function (t) { pieceLength: 5, announce: [announceUrl] } - seeder.seed([stream], seederOpts, function (torrent) { + seeder.seed([stream], seederOpts, torrent => { magnetURI = torrent.magnetURI cb(null) }) }, - function (cb) { + cb => { client = new WebTorrent({ dht: false, lsd: false }) - 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) }) - client.add(magnetURI, function (dl) { + client.add(magnetURI, dl => { t.equal(dl.files.length, 1) t.equal(dl.files[0].name, 'hello.txt') t.equal(dl.files[0].length, 12) - dl.files[0].getBuffer(function (err, buf) { + dl.files[0].getBuffer((err, buf) => { t.error(err) t.equal(buf.toString('utf8'), 'HELLO WORLD\n', 'content') @@ -62,10 +62,10 @@ test('client.seed: stream', function (t) { }) }) } - ], function (err) { + ], err => { t.error(err) - seeder.destroy(function (err) { t.error(err, 'seeder destroyed') }) - client.destroy(function (err) { t.error(err, 'client destroyed') }) - tracker.close(function () { t.pass('tracker closed') }) + seeder.destroy(err => { t.error(err, 'seeder destroyed') }) + client.destroy(err => { t.error(err, 'client destroyed') }) + tracker.close(() => { t.pass('tracker closed') }) }) }) |