test: server: check that all clients, server are destroyed

This commit is contained in:
Feross Aboukhadijeh 2017-02-08 13:11:48 -08:00
parent e731106279
commit 4422067607

View File

@ -12,7 +12,7 @@ var peerId2 = Buffer.from('12345678901234567890')
var peerId3 = Buffer.from('23456789012345678901') var peerId3 = Buffer.from('23456789012345678901')
function serverTest (t, serverType, serverFamily) { function serverTest (t, serverType, serverFamily) {
t.plan(36) t.plan(40)
var hostname = serverFamily === 'inet6' var hostname = serverFamily === 'inet6'
? '[::1]' ? '[::1]'
@ -138,16 +138,23 @@ function serverTest (t, serverType, serverFamily) {
t.equal(data.incomplete, 1) t.equal(data.incomplete, 1)
client2.destroy(function () { client2.destroy(function () {
t.pass('client2 destroyed')
client3.stop() client3.stop()
client3.once('update', function (data) { client3.once('update', function (data) {
t.equal(data.announce, announceUrl) t.equal(data.announce, announceUrl)
t.equal(data.complete, 1) t.equal(data.complete, 1)
t.equal(data.incomplete, 0) t.equal(data.incomplete, 0)
client3.destroy(function () {
client1.destroy(function () { client1.destroy(function () {
server.close() t.pass('client1 destroyed')
}) })
client3.destroy(function () {
t.pass('client3 destroyed')
})
server.close(function () {
t.pass('server destroyed')
}) })
}) })
}) })