bittorrent-tracker/test/client-large-torrent.js

64 lines
1.6 KiB
JavaScript
Raw Normal View History

var Client = require('../')
var common = require('./common')
2016-03-16 19:22:33 +00:00
var fixtures = require('webtorrent-fixtures')
2014-04-19 06:08:17 +00:00
var test = require('tape')
var peerId = new Buffer('01234567890123456789')
function testLargeTorrent (t, serverType) {
t.plan(9)
2014-04-19 06:08:17 +00:00
common.createServer(t, serverType, function (server, announceUrl) {
var client = new Client({
infoHash: fixtures.sintel.parsedTorrent.infoHash,
peerId: peerId,
port: 6881,
announce: announceUrl,
wrtc: {}
})
2014-04-19 06:08:17 +00:00
if (serverType === 'ws') common.mockWebsocketTracker(client)
client.on('error', function (err) { t.error(err) })
client.on('warning', function (err) { t.error(err) })
client.once('update', function (data) {
t.equal(data.announce, announceUrl)
t.equal(typeof data.complete, 'number')
t.equal(typeof data.incomplete, 'number')
2014-05-24 04:02:53 +00:00
client.update()
client.once('update', function (data) {
t.equal(data.announce, announceUrl)
t.equal(typeof data.complete, 'number')
t.equal(typeof data.incomplete, 'number')
client.stop()
client.once('update', function (data) {
t.equal(data.announce, announceUrl)
t.equal(typeof data.complete, 'number')
t.equal(typeof data.incomplete, 'number')
2014-05-24 04:02:53 +00:00
server.close()
client.destroy()
})
2014-05-24 03:43:45 +00:00
})
2014-05-24 04:02:53 +00:00
})
client.start()
})
}
test('http: large torrent: client.start()', function (t) {
testLargeTorrent(t, 'http')
})
test('udp: large torrent: client.start()', function (t) {
testLargeTorrent(t, 'udp')
})
test('ws: large torrent: client.start()', function (t) {
testLargeTorrent(t, 'ws')
2014-04-19 06:08:17 +00:00
})