Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-01-04 06:59:28 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-01-04 06:59:28 +0300
commit09e345eb12f30f73e9492c7a6921a4442226e38e (patch)
tree9d72c741274fc34547eb2f7143ebba8f83a4fef9 /test/download-dht-magnet.js
parent8b36f9d607c4acf3b439278b5a6e1e8b72be6eb9 (diff)
test: verify file content in download tests
Diffstat (limited to 'test/download-dht-magnet.js')
-rw-r--r--test/download-dht-magnet.js12
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 () {