From cd7fcb2d797cccf9507557493146e6a498f16861 Mon Sep 17 00:00:00 2001 From: Jonathan Harper Date: Tue, 26 Apr 2016 20:59:29 -0700 Subject: Torrent emits 'noPeers' even when swarm is empty after announce --- test/node/download-dht-torrent.js | 9 ++++++++- test/node/download-tracker-magnet.js | 6 +++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'test/node') diff --git a/test/node/download-dht-torrent.js b/test/node/download-dht-torrent.js index 20c7b0c..874288d 100644 --- a/test/node/download-dht-torrent.js +++ b/test/node/download-dht-torrent.js @@ -53,10 +53,17 @@ test('Download using DHT (via .torrent file)', function (t) { maybeDone(null) }) + torrent.on('noPeers', function (announceType) { + t.equal(announceType, 'dht', 'noPeers event seen with correct announceType') + noPeersFound = true + maybeDone(null) + }) + var announced = false var loaded = false + var noPeersFound = false function maybeDone (err) { - if ((announced && loaded) || err) cb(err, client1) + if ((announced && loaded && noPeersFound) || err) cb(err, client1) } }, diff --git a/test/node/download-tracker-magnet.js b/test/node/download-tracker-magnet.js index a310350..7224895 100644 --- a/test/node/download-tracker-magnet.js +++ b/test/node/download-tracker-magnet.js @@ -15,7 +15,7 @@ test('Download using HTTP tracker (via magnet uri)', function (t) { }) function magnetDownloadTest (t, serverType) { - t.plan(9) + t.plan(10) var tracker = new TrackerServer( serverType === 'udp' ? { http: false, ws: false } : { udp: false, ws: false } @@ -59,6 +59,10 @@ function magnetDownloadTest (t, serverType) { 'Leaves of Grass by Walt Whitman.epub' ] + torrent.on('noPeers', function (announceType) { + t.equal(announceType, 'tracker', 'noPeers event seen with correct announceType') + }) + t.deepEqual(torrent.files.map(function (file) { return file.name }), names) torrent.load(fs.createReadStream(fixtures.leaves.contentPath), function (err) { -- cgit v1.2.3