diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-08-24 01:25:38 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-08-24 01:25:38 +0300 |
commit | 931a10c0fdb86ad926d586558db5102b13c7065d (patch) | |
tree | 1875f375e1c6fd401bf41fa2d940acb3676df63f /test/blocklist-dht.js | |
parent | 1fc60bb9d5fc3d73b6035b8ef48cdea64bba4289 (diff) |
improve tests to pass when verifying torrent data
Diffstat (limited to 'test/blocklist-dht.js')
-rw-r--r-- | test/blocklist-dht.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/test/blocklist-dht.js b/test/blocklist-dht.js index 3e8710b..6d4c1c9 100644 --- a/test/blocklist-dht.js +++ b/test/blocklist-dht.js @@ -13,7 +13,7 @@ var leavesParsed = parseTorrent(leavesTorrent) leavesParsed.announce = [] test('blocklist blocks peers discovered via DHT', function (t) { - t.plan(7) + t.plan(8) var dhtServer = new DHT({ bootstrap: false }) @@ -38,13 +38,6 @@ test('blocklist blocks peers discovered via DHT', function (t) { var torrent1 = client1.add(leavesParsed) - client1.on('torrent', function () { - torrent1.on('dhtAnnounce', function () { - t.pass('client1 announced to dht') - cb(null, client1) - }) - }) - torrent1.on('peer', function () { t.fail('client1 should not find any peers') }) @@ -52,6 +45,25 @@ test('blocklist blocks peers discovered via DHT', function (t) { torrent1.on('blockedPeer', function () { t.fail('client1 should not block any peers') }) + + torrent1.on('ready', function () { + t.pass('torrent1 ready') + torrentReady = true + maybeDone() + }) + + torrent1.on('dhtAnnounce', function () { + t.pass('client1 announced to dht') + announced = true + maybeDone() + }) + + var torrentReady = false + var announced = false + function maybeDone () { + if (torrentReady && announced) cb(null, client1) + } + }], client2: ['client1', function (cb, r) { |