diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-08-22 18:17:32 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-08-22 18:17:32 +0300 |
commit | f910c34cce10a99411be304521e63afed397865b (patch) | |
tree | c846cb530bbe3b411a242ade8a22835c8f279508 /test | |
parent | b1f87ef4bba5c07994ed7363ddf4e99ef794ab1e (diff) |
test: don't assume event ordering
Diffstat (limited to 'test')
-rw-r--r-- | test/download-dht-torrent.js | 11 |
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) { |