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
path: root/test
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-08-22 18:17:32 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-08-22 18:17:32 +0300
commitf910c34cce10a99411be304521e63afed397865b (patch)
treec846cb530bbe3b411a242ade8a22835c8f279508 /test
parentb1f87ef4bba5c07994ed7363ddf4e99ef794ab1e (diff)
test: don't assume event ordering
Diffstat (limited to 'test')
-rw-r--r--test/download-dht-torrent.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/download-dht-torrent.js b/test/download-dht-torrent.js
index cda235a..50e2013 100644
--- a/test/download-dht-torrent.js
+++ b/test/download-dht-torrent.js
@@ -77,13 +77,22 @@ test('Download using DHT (via .torrent file)', function (t) {
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 torrentDone = false
+ var gotBuffer = false
+ function maybeDone () {
+ if (torrentDone && gotBuffer) cb(null, client2)
+ }
})
}]
}, function (err, r) {