mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-13 10:56:25 +00:00
wait for server close before next test
This commit is contained in:
parent
0ff2c1917b
commit
14034c2848
@ -8,10 +8,9 @@ var test = require('tape')
|
|||||||
var torrent = fs.readFileSync(__dirname + '/torrents/sintel-5gb.torrent')
|
var torrent = fs.readFileSync(__dirname + '/torrents/sintel-5gb.torrent')
|
||||||
var parsedTorrent = parseTorrent(torrent)
|
var parsedTorrent = parseTorrent(torrent)
|
||||||
var peerId = new Buffer('01234567890123456789')
|
var peerId = new Buffer('01234567890123456789')
|
||||||
var port = 6881
|
|
||||||
|
|
||||||
test('large torrent: client.start()', function (t) {
|
test('large torrent: client.start()', function (t) {
|
||||||
t.plan(5)
|
t.plan(6)
|
||||||
|
|
||||||
var server = new Server({ http: false })
|
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
|
// remove all tracker servers except a single UDP one, for now
|
||||||
parsedTorrent.announce = [ 'udp://127.0.0.1:' + port + '/announce' ]
|
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) {
|
client.on('error', function (err) {
|
||||||
t.error(err)
|
t.error(err)
|
||||||
@ -45,7 +44,9 @@ test('large torrent: client.start()', function (t) {
|
|||||||
client.once('peer', function (addr) {
|
client.once('peer', function (addr) {
|
||||||
t.pass('there is at least one peer') // TODO: this shouldn't rely on an external server!
|
t.pass('there is at least one peer') // TODO: this shouldn't rely on an external server!
|
||||||
client.stop()
|
client.stop()
|
||||||
server.close()
|
server.close(function () {
|
||||||
|
t.pass('server close')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
client.start()
|
client.start()
|
||||||
|
@ -9,7 +9,7 @@ var peerId2 = '12345678901234567890'
|
|||||||
var torrentLength = 50000
|
var torrentLength = 50000
|
||||||
|
|
||||||
test('server', function (t) {
|
test('server', function (t) {
|
||||||
t.plan(26)
|
t.plan(27)
|
||||||
|
|
||||||
var server = new Server({ udp: false }) // { interval: 50000, compactOnly: false }
|
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.complete, 0)
|
||||||
t.equal(data.incomplete, 0)
|
t.equal(data.incomplete, 0)
|
||||||
|
|
||||||
server.close()
|
server.close(function () {
|
||||||
|
t.pass('server closed')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -9,7 +9,7 @@ var peerId2 = '12345678901234567890'
|
|||||||
var torrentLength = 50000
|
var torrentLength = 50000
|
||||||
|
|
||||||
test('server', function (t) {
|
test('server', function (t) {
|
||||||
t.plan(26)
|
t.plan(27)
|
||||||
|
|
||||||
var server = new Server({ http: false })
|
var server = new Server({ http: false })
|
||||||
|
|
||||||
@ -100,7 +100,9 @@ test('server', function (t) {
|
|||||||
t.equal(data.complete, 0)
|
t.equal(data.complete, 0)
|
||||||
t.equal(data.incomplete, 0)
|
t.equal(data.incomplete, 0)
|
||||||
|
|
||||||
server.close()
|
server.close(function () {
|
||||||
|
t.pass('server close')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user