diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-08-24 01:25:38 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-08-24 01:25:38 +0300 |
commit | 931a10c0fdb86ad926d586558db5102b13c7065d (patch) | |
tree | 1875f375e1c6fd401bf41fa2d940acb3676df63f /test/download-tracker-magnet.js | |
parent | 1fc60bb9d5fc3d73b6035b8ef48cdea64bba4289 (diff) |
improve tests to pass when verifying torrent data
Diffstat (limited to 'test/download-tracker-magnet.js')
-rw-r--r-- | test/download-tracker-magnet.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/download-tracker-magnet.js b/test/download-tracker-magnet.js index 43ed393..0aac1fb 100644 --- a/test/download-tracker-magnet.js +++ b/test/download-tracker-magnet.js @@ -27,7 +27,7 @@ function magnetDownloadTest (t, serverType) { auto({ tracker: function (cb) { var tracker = new TrackerServer( - serverType === 'udp' ? { http: false } : { udp: false } + serverType === 'udp' ? { http: false, ws: false } : { udp: false, ws: false } ) tracker.on('error', function (err) { t.fail(err) }) @@ -84,13 +84,22 @@ function magnetDownloadTest (t, serverType) { file.getBuffer(function (err, buf) { if (err) throw err t.deepEqual(buf, leavesFile, 'downloaded correct content') + gotBuffer = true + maybeDone() }) }) torrent.once('done', function () { t.pass('client2 downloaded torrent from client1') - cb(null, client2) + torrentDone = true + maybeDone() }) + + var gotBuffer = false + var torrentDone = false + function maybeDone () { + if (gotBuffer && torrentDone) cb(null, client2) + } }) }] |