mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +00:00
Merge pull request #341 from LinusU/object-shorthand
This commit is contained in:
commit
04dd528c27
@ -11,7 +11,7 @@ function testLargeTorrent (t, serverType) {
|
|||||||
common.createServer(t, serverType, function (server, announceUrl) {
|
common.createServer(t, serverType, function (server, announceUrl) {
|
||||||
var client = new Client({
|
var client = new Client({
|
||||||
infoHash: fixtures.sintel.parsedTorrent.infoHash,
|
infoHash: fixtures.sintel.parsedTorrent.infoHash,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
|
@ -15,7 +15,7 @@ function testMagnet (t, serverType) {
|
|||||||
var client = new Client({
|
var client = new Client({
|
||||||
infoHash: parsedTorrent.infoHash,
|
infoHash: parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
@ -13,8 +13,8 @@ test('ensure client.destroy() callback is called with re-used websockets in sock
|
|||||||
var client1 = new Client({
|
var client1 = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -30,8 +30,8 @@ test('ensure client.destroy() callback is called with re-used websockets in sock
|
|||||||
var client2 = new Client({
|
var client2 = new Client({
|
||||||
infoHash: fixtures.alice.parsedTorrent.infoHash, // different info hash
|
infoHash: fixtures.alice.parsedTorrent.infoHash, // different info hash
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ function testClientStart (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ function testClientStop (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ function testClientStopDestroy (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ function testClientUpdate (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ function testClientScrape (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ function testClientAnnounceWithParams (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ function testClientGetAnnounceOpts (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
getAnnounceOpts: function () {
|
getAnnounceOpts: function () {
|
||||||
return {
|
return {
|
||||||
testParam: 'this is a test'
|
testParam: 'this is a test'
|
||||||
@ -358,7 +358,7 @@ function testClientAnnounceWithNumWant (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -449,7 +449,7 @@ test('http: userAgent', function (t) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
userAgent: 'WebTorrent/0.98.0 (https://webtorrent.io)',
|
userAgent: 'WebTorrent/0.98.0 (https://webtorrent.io)',
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
@ -476,7 +476,7 @@ function testSupportedTracker (t, serverType) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ function testUnsupportedTracker (t, announceUrl) {
|
|||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId1,
|
peerId: peerId1,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ function testNoEventsAfterDestroy (t, serverType) {
|
|||||||
var client = new Client({
|
var client = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: port,
|
port,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
: '127.0.0.1'
|
: '127.0.0.1'
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
serverType: serverType,
|
serverType,
|
||||||
peersCacheLength: 2 // LRU cache can only contain a max of 2 peers
|
peersCacheLength: 2 // LRU cache can only contain a max of 2 peers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,11 +27,11 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
var announceUrl = serverType + '://' + hostname + ':' + port + '/announce'
|
var announceUrl = serverType + '://' + hostname + ':' + port + '/announce'
|
||||||
|
|
||||||
var client1 = new Client({
|
var client1 = new Client({
|
||||||
infoHash: infoHash,
|
infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: wrtc
|
wrtc
|
||||||
})
|
})
|
||||||
if (serverType === 'ws') common.mockWebsocketTracker(client1)
|
if (serverType === 'ws') common.mockWebsocketTracker(client1)
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
|
|
||||||
client1.once('update', function (data) {
|
client1.once('update', function (data) {
|
||||||
var client2 = new Client({
|
var client2 = new Client({
|
||||||
infoHash: infoHash,
|
infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId2,
|
peerId: peerId2,
|
||||||
port: 6882,
|
port: 6882,
|
||||||
wrtc: wrtc
|
wrtc
|
||||||
})
|
})
|
||||||
if (serverType === 'ws') common.mockWebsocketTracker(client2)
|
if (serverType === 'ws') common.mockWebsocketTracker(client2)
|
||||||
|
|
||||||
@ -64,11 +64,11 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
var client3 = new Client({
|
var client3 = new Client({
|
||||||
infoHash: infoHash,
|
infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId3,
|
peerId: peerId3,
|
||||||
port: 6880,
|
port: 6880,
|
||||||
wrtc: wrtc
|
wrtc
|
||||||
})
|
})
|
||||||
if (serverType === 'ws') common.mockWebsocketTracker(client3)
|
if (serverType === 'ws') common.mockWebsocketTracker(client3)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ var peerId = Buffer.from('01234567890123456789')
|
|||||||
function testFilterOption (t, serverType) {
|
function testFilterOption (t, serverType) {
|
||||||
t.plan(8)
|
t.plan(8)
|
||||||
|
|
||||||
var opts = { serverType: serverType } // this is test-suite-only option
|
var opts = { serverType } // this is test-suite-only option
|
||||||
opts.filter = function (infoHash, params, cb) {
|
opts.filter = function (infoHash, params, cb) {
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
if (infoHash === fixtures.alice.parsedTorrent.infoHash) {
|
if (infoHash === fixtures.alice.parsedTorrent.infoHash) {
|
||||||
@ -23,7 +23,7 @@ function testFilterOption (t, serverType) {
|
|||||||
var client1 = new Client({
|
var client1 = new Client({
|
||||||
infoHash: fixtures.alice.parsedTorrent.infoHash,
|
infoHash: fixtures.alice.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
@ -40,7 +40,7 @@ function testFilterOption (t, serverType) {
|
|||||||
var client2 = new Client({
|
var client2 = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
@ -88,7 +88,7 @@ test('ws: filter option blocks tracker from tracking torrent', function (t) {
|
|||||||
function testFilterCustomError (t, serverType) {
|
function testFilterCustomError (t, serverType) {
|
||||||
t.plan(8)
|
t.plan(8)
|
||||||
|
|
||||||
var opts = { serverType: serverType } // this is test-suite-only option
|
var opts = { serverType } // this is test-suite-only option
|
||||||
opts.filter = function (infoHash, params, cb) {
|
opts.filter = function (infoHash, params, cb) {
|
||||||
process.nextTick(function () {
|
process.nextTick(function () {
|
||||||
if (infoHash === fixtures.alice.parsedTorrent.infoHash) {
|
if (infoHash === fixtures.alice.parsedTorrent.infoHash) {
|
||||||
@ -103,7 +103,7 @@ function testFilterCustomError (t, serverType) {
|
|||||||
var client1 = new Client({
|
var client1 = new Client({
|
||||||
infoHash: fixtures.alice.parsedTorrent.infoHash,
|
infoHash: fixtures.alice.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
@ -119,7 +119,7 @@ function testFilterCustomError (t, serverType) {
|
|||||||
var client2 = new Client({
|
var client2 = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
@ -9,7 +9,7 @@ var peerId = Buffer.from('01234567890123456789')
|
|||||||
function testRequestHandler (t, serverType) {
|
function testRequestHandler (t, serverType) {
|
||||||
t.plan(5)
|
t.plan(5)
|
||||||
|
|
||||||
var opts = { serverType: serverType } // this is test-suite-only option
|
var opts = { serverType } // this is test-suite-only option
|
||||||
|
|
||||||
class Swarm extends Server.Swarm {
|
class Swarm extends Server.Swarm {
|
||||||
announce (params, cb) {
|
announce (params, cb) {
|
||||||
@ -33,7 +33,7 @@ function testRequestHandler (t, serverType) {
|
|||||||
var client1 = new Client({
|
var client1 = new Client({
|
||||||
infoHash: fixtures.alice.parsedTorrent.infoHash,
|
infoHash: fixtures.alice.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
|
@ -14,7 +14,7 @@ function testSingle (t, serverType) {
|
|||||||
var client = new Client({
|
var client = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: {}
|
wrtc: {}
|
||||||
})
|
})
|
||||||
@ -199,7 +199,7 @@ test('server: all info_hash scrape (manual http request)', function (t) {
|
|||||||
var client = new Client({
|
var client = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881
|
port: 6881
|
||||||
})
|
})
|
||||||
client.on('error', function (err) { t.error(err) })
|
client.on('error', function (err) { t.error(err) })
|
||||||
|
@ -19,7 +19,7 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
: '127.0.0.1'
|
: '127.0.0.1'
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
serverType: serverType
|
serverType
|
||||||
}
|
}
|
||||||
|
|
||||||
common.createServer(t, opts, function (server) {
|
common.createServer(t, opts, function (server) {
|
||||||
@ -29,11 +29,11 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
var announceUrl = serverType + '://' + hostname + ':' + port + '/announce'
|
var announceUrl = serverType + '://' + hostname + ':' + port + '/announce'
|
||||||
|
|
||||||
var client1 = new Client({
|
var client1 = new Client({
|
||||||
infoHash: infoHash,
|
infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881,
|
port: 6881,
|
||||||
wrtc: wrtc
|
wrtc
|
||||||
})
|
})
|
||||||
if (serverType === 'ws') common.mockWebsocketTracker(client1)
|
if (serverType === 'ws') common.mockWebsocketTracker(client1)
|
||||||
|
|
||||||
@ -89,11 +89,11 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
t.equal(typeof data.downloaded, 'number')
|
t.equal(typeof data.downloaded, 'number')
|
||||||
|
|
||||||
var client2 = new Client({
|
var client2 = new Client({
|
||||||
infoHash: infoHash,
|
infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId2,
|
peerId: peerId2,
|
||||||
port: 6882,
|
port: 6882,
|
||||||
wrtc: wrtc
|
wrtc
|
||||||
})
|
})
|
||||||
if (serverType === 'ws') common.mockWebsocketTracker(client2)
|
if (serverType === 'ws') common.mockWebsocketTracker(client2)
|
||||||
|
|
||||||
@ -109,11 +109,11 @@ function serverTest (t, serverType, serverFamily) {
|
|||||||
t.equal(data.incomplete, 1)
|
t.equal(data.incomplete, 1)
|
||||||
|
|
||||||
var client3 = new Client({
|
var client3 = new Client({
|
||||||
infoHash: infoHash,
|
infoHash,
|
||||||
announce: [announceUrl],
|
announce: [announceUrl],
|
||||||
peerId: peerId3,
|
peerId: peerId3,
|
||||||
port: 6880,
|
port: 6880,
|
||||||
wrtc: wrtc
|
wrtc
|
||||||
})
|
})
|
||||||
if (serverType === 'ws') common.mockWebsocketTracker(client3)
|
if (serverType === 'ws') common.mockWebsocketTracker(client3)
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ test('server: get leecher stats.json', function (t) {
|
|||||||
var client = new Client({
|
var client = new Client({
|
||||||
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
infoHash: fixtures.leaves.parsedTorrent.infoHash,
|
||||||
announce: announceUrl,
|
announce: announceUrl,
|
||||||
peerId: peerId,
|
peerId,
|
||||||
port: 6881
|
port: 6881
|
||||||
})
|
})
|
||||||
client.on('error', function (err) { t.error(err) })
|
client.on('error', function (err) { t.error(err) })
|
||||||
|
Loading…
Reference in New Issue
Block a user