mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-13 10:56:25 +00:00
add more thorough server tests
This commit is contained in:
parent
c61009eceb
commit
60b7f8dd09
@ -3,12 +3,12 @@ var portfinder = require('portfinder')
|
|||||||
var Server = require('../').Server
|
var Server = require('../').Server
|
||||||
var test = require('tape')
|
var test = require('tape')
|
||||||
|
|
||||||
var peerId = new Buffer('12345678901234567890')
|
var infoHash = '4cb67059ed6bd08362da625b3ae77f6f4a075705'
|
||||||
var infoHash = new Buffer('4cb67059ed6bd08362da625b3ae77f6f4a075705', 'hex')
|
var peerId = '12345678901234567890'
|
||||||
var torrentLength = 50000
|
var torrentLength = 50000
|
||||||
|
|
||||||
test('server', function (t) {
|
test('server', function (t) {
|
||||||
t.plan(12)
|
t.plan(17)
|
||||||
|
|
||||||
var server = new Server() // { interval: 50000, compactOnly: false }
|
var server = new Server() // { interval: 50000, compactOnly: false }
|
||||||
|
|
||||||
@ -27,12 +27,6 @@ test('server', function (t) {
|
|||||||
t.pass('server listening')
|
t.pass('server listening')
|
||||||
})
|
})
|
||||||
|
|
||||||
// server.torrents //
|
|
||||||
// server.torrents[infoHash] //
|
|
||||||
// server.torrents[infoHash].complete //
|
|
||||||
// server.torrents[infoHash].incomplete //
|
|
||||||
// server.torrents[infoHash].peers //
|
|
||||||
|
|
||||||
portfinder.getPort(function (err, port) {
|
portfinder.getPort(function (err, port) {
|
||||||
t.error(err, 'found free port')
|
t.error(err, 'found free port')
|
||||||
server.listen(port)
|
server.listen(port)
|
||||||
@ -52,6 +46,16 @@ test('server', function (t) {
|
|||||||
t.equal(data.complete, 0)
|
t.equal(data.complete, 0)
|
||||||
t.equal(data.incomplete, 1)
|
t.equal(data.incomplete, 1)
|
||||||
|
|
||||||
|
t.equal(Object.keys(server.torrents).length, 1)
|
||||||
|
t.equal(server.torrents[infoHash].complete, 0)
|
||||||
|
t.equal(server.torrents[infoHash].incomplete, 1)
|
||||||
|
t.equal(Object.keys(server.torrents[infoHash].peers).length, 1)
|
||||||
|
t.deepEqual(server.torrents[infoHash].peers['127.0.0.1:6881'], {
|
||||||
|
ip: '127.0.0.1',
|
||||||
|
port: 6881,
|
||||||
|
peerId: peerId
|
||||||
|
})
|
||||||
|
|
||||||
client.complete()
|
client.complete()
|
||||||
|
|
||||||
client.once('update', function (data) {
|
client.once('update', function (data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user