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-magnet.js | |
parent | 8b36f9d607c4acf3b439278b5a6e1e8b72be6eb9 (diff) |
test: verify file content in download tests
Diffstat (limited to 'test/download-dht-magnet.js')
-rw-r--r-- | test/download-dht-magnet.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/test/download-dht-magnet.js b/test/download-dht-magnet.js index 1a0b3bc..639f485 100644 --- a/test/download-dht-magnet.js +++ b/test/download-dht-magnet.js @@ -5,7 +5,8 @@ var parseTorrent = require('parse-torrent') var test = require('tape') var WebTorrent = require('../') -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 magnet uri)', function (t) { - t.plan(7) + t.plan(8) var dhtServer = new DHT({ bootstrap: false }) dhtServer.on('error', function (err) { @@ -55,7 +56,7 @@ test('Download using DHT (via magnet uri)', function (t) { maybeDone(null) }) - torrent.storage.load(fs.createReadStream(leavesFile), function (err) { + torrent.storage.load(fs.createReadStream(leavesPath), function (err) { wroteStorage = true maybeDone(err) }) @@ -73,7 +74,10 @@ test('Download using DHT (via magnet uri)', 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 () { |