diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-01-04 06:59:28 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-01-04 06:59:28 +0300 |
commit | 09e345eb12f30f73e9492c7a6921a4442226e38e (patch) | |
tree | 9d72c741274fc34547eb2f7143ebba8f83a4fef9 /test/download-dht-torrent.js | |
parent | 8b36f9d607c4acf3b439278b5a6e1e8b72be6eb9 (diff) |
test: verify file content in download tests
Diffstat (limited to 'test/download-dht-torrent.js')
-rw-r--r-- | test/download-dht-torrent.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/test/download-dht-torrent.js b/test/download-dht-torrent.js index 19b998e..0e38512 100644 --- a/test/download-dht-torrent.js +++ b/test/download-dht-torrent.js @@ -5,7 +5,8 @@ var fs = require('fs') var parseTorrent = require('parse-torrent') var test = require('tape') -var leavesFile = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' +var leavesPath = __dirname + '/content/Leaves of Grass by Walt Whitman.epub' +var leavesFile = fs.readFileSync(leavesPath) var leavesTorrent = fs.readFileSync(__dirname + '/torrents/leaves.torrent') var leavesParsed = parseTorrent(leavesTorrent) @@ -14,7 +15,7 @@ leavesParsed.announce = [] leavesParsed.announceList = [] test('Download using DHT (via .torrent file)', function (t) { - t.plan(7) + t.plan(8) var dhtServer = new DHT({ bootstrap: false }) @@ -54,7 +55,7 @@ test('Download using DHT (via .torrent file)', function (t) { maybeDone(null) }) - torrent.storage.load(fs.createReadStream(leavesFile), function (err) { + torrent.storage.load(fs.createReadStream(leavesPath), function (err) { wroteStorage = true maybeDone(err) }) @@ -72,7 +73,10 @@ test('Download using DHT (via .torrent file)', function (t) { client2.on('torrent', function (torrent) { torrent.files.forEach(function (file) { - file.createReadStream() + file.getBuffer(function (err, buf) { + if (err) throw err + t.deepEqual(buf, leavesFile, 'downloaded correct content') + }) }) torrent.once('done', function () { |