From 14034c2848d156d643de1e829622a2a8949a7e46 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 23 May 2014 20:43:45 -0700 Subject: [PATCH] wait for server close before next test --- test/client-large-torrent.js | 9 +++++---- test/server.js | 6 ++++-- test/udp-server.js | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/client-large-torrent.js b/test/client-large-torrent.js index 53ae354..8333eee 100644 --- a/test/client-large-torrent.js +++ b/test/client-large-torrent.js @@ -8,10 +8,9 @@ var test = require('tape') var torrent = fs.readFileSync(__dirname + '/torrents/sintel-5gb.torrent') var parsedTorrent = parseTorrent(torrent) var peerId = new Buffer('01234567890123456789') -var port = 6881 test('large torrent: client.start()', function (t) { - t.plan(5) + t.plan(6) var server = new Server({ http: false }) @@ -30,7 +29,7 @@ test('large torrent: client.start()', function (t) { // remove all tracker servers except a single UDP one, for now parsedTorrent.announce = [ 'udp://127.0.0.1:' + port + '/announce' ] - var client = new Client(peerId, port, parsedTorrent) + var client = new Client(peerId, 6881, parsedTorrent) client.on('error', function (err) { t.error(err) @@ -45,7 +44,9 @@ test('large torrent: client.start()', function (t) { client.once('peer', function (addr) { t.pass('there is at least one peer') // TODO: this shouldn't rely on an external server! client.stop() - server.close() + server.close(function () { + t.pass('server close') + }) }) client.start() diff --git a/test/server.js b/test/server.js index b1f200b..1b6990d 100644 --- a/test/server.js +++ b/test/server.js @@ -9,7 +9,7 @@ var peerId2 = '12345678901234567890' var torrentLength = 50000 test('server', function (t) { - t.plan(26) + t.plan(27) var server = new Server({ udp: false }) // { interval: 50000, compactOnly: false } @@ -100,7 +100,9 @@ test('server', function (t) { t.equal(data.complete, 0) t.equal(data.incomplete, 0) - server.close() + server.close(function () { + t.pass('server closed') + }) }) }) }) diff --git a/test/udp-server.js b/test/udp-server.js index 3cf0e34..1f85e09 100644 --- a/test/udp-server.js +++ b/test/udp-server.js @@ -9,7 +9,7 @@ var peerId2 = '12345678901234567890' var torrentLength = 50000 test('server', function (t) { - t.plan(26) + t.plan(27) var server = new Server({ http: false }) @@ -100,7 +100,9 @@ test('server', function (t) { t.equal(data.complete, 0) t.equal(data.incomplete, 0) - server.close() + server.close(function () { + t.pass('server close') + }) }) }) })