Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use object shorthand for properties #341

Merged
merged 1 commit into from May 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/client-large-torrent.js
Expand Up @@ -11,7 +11,7 @@ function testLargeTorrent (t, serverType) {
common.createServer(t, serverType, function (server, announceUrl) {
var client = new Client({
infoHash: fixtures.sintel.parsedTorrent.infoHash,
peerId: peerId,
peerId,
port: 6881,
announce: announceUrl,
wrtc: {}
Expand Down
2 changes: 1 addition & 1 deletion test/client-magnet.js
Expand Up @@ -15,7 +15,7 @@ function testMagnet (t, serverType) {
var client = new Client({
infoHash: parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand Down
8 changes: 4 additions & 4 deletions test/client-ws-socket-pool.js
Expand Up @@ -13,8 +13,8 @@ test('ensure client.destroy() callback is called with re-used websockets in sock
var client1 = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
port: port,
peerId,
port,
wrtc: {}
})

Expand All @@ -30,8 +30,8 @@ test('ensure client.destroy() callback is called with re-used websockets in sock
var client2 = new Client({
infoHash: fixtures.alice.parsedTorrent.infoHash, // different info hash
announce: announceUrl,
peerId: peerId,
port: port,
peerId,
port,
wrtc: {}
})

Expand Down
22 changes: 11 additions & 11 deletions test/client.js
Expand Up @@ -16,7 +16,7 @@ function testClientStart (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -62,7 +62,7 @@ function testClientStop (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -110,7 +110,7 @@ function testClientStopDestroy (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -164,7 +164,7 @@ function testClientUpdate (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -217,7 +217,7 @@ function testClientScrape (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -259,7 +259,7 @@ function testClientAnnounceWithParams (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -307,7 +307,7 @@ function testClientGetAnnounceOpts (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
getAnnounceOpts: function () {
return {
testParam: 'this is a test'
Expand Down Expand Up @@ -358,7 +358,7 @@ function testClientAnnounceWithNumWant (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: [announceUrl],
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -449,7 +449,7 @@ test('http: userAgent', function (t) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
userAgent: 'WebTorrent/0.98.0 (https://webtorrent.io)',
wrtc: {}
})
Expand All @@ -476,7 +476,7 @@ function testSupportedTracker (t, serverType) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down Expand Up @@ -514,7 +514,7 @@ function testUnsupportedTracker (t, announceUrl) {
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId1,
port: port,
port,
wrtc: {}
})

Expand Down
4 changes: 2 additions & 2 deletions test/destroy.js
Expand Up @@ -13,8 +13,8 @@ function testNoEventsAfterDestroy (t, serverType) {
var client = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
port: port,
peerId,
port,
wrtc: {}
})

Expand Down
16 changes: 8 additions & 8 deletions test/evict.js
Expand Up @@ -16,7 +16,7 @@ function serverTest (t, serverType, serverFamily) {
: '127.0.0.1'

var opts = {
serverType: serverType,
serverType,
peersCacheLength: 2 // LRU cache can only contain a max of 2 peers
}

Expand All @@ -27,23 +27,23 @@ function serverTest (t, serverType, serverFamily) {
var announceUrl = serverType + '://' + hostname + ':' + port + '/announce'

var client1 = new Client({
infoHash: infoHash,
infoHash,
announce: [announceUrl],
peerId: peerId,
peerId,
port: 6881,
wrtc: wrtc
wrtc
})
if (serverType === 'ws') common.mockWebsocketTracker(client1)

client1.start()

client1.once('update', function (data) {
var client2 = new Client({
infoHash: infoHash,
infoHash,
announce: [announceUrl],
peerId: peerId2,
port: 6882,
wrtc: wrtc
wrtc
})
if (serverType === 'ws') common.mockWebsocketTracker(client2)

Expand All @@ -64,11 +64,11 @@ function serverTest (t, serverType, serverFamily) {
})

var client3 = new Client({
infoHash: infoHash,
infoHash,
announce: [announceUrl],
peerId: peerId3,
port: 6880,
wrtc: wrtc
wrtc
})
if (serverType === 'ws') common.mockWebsocketTracker(client3)

Expand Down
12 changes: 6 additions & 6 deletions test/filter.js
Expand Up @@ -8,7 +8,7 @@ var peerId = Buffer.from('01234567890123456789')
function testFilterOption (t, serverType) {
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) {
process.nextTick(function () {
if (infoHash === fixtures.alice.parsedTorrent.infoHash) {
Expand All @@ -23,7 +23,7 @@ function testFilterOption (t, serverType) {
var client1 = new Client({
infoHash: fixtures.alice.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand All @@ -40,7 +40,7 @@ function testFilterOption (t, serverType) {
var client2 = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand Down Expand Up @@ -88,7 +88,7 @@ test('ws: filter option blocks tracker from tracking torrent', function (t) {
function testFilterCustomError (t, serverType) {
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) {
process.nextTick(function () {
if (infoHash === fixtures.alice.parsedTorrent.infoHash) {
Expand All @@ -103,7 +103,7 @@ function testFilterCustomError (t, serverType) {
var client1 = new Client({
infoHash: fixtures.alice.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand All @@ -119,7 +119,7 @@ function testFilterCustomError (t, serverType) {
var client2 = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand Down
4 changes: 2 additions & 2 deletions test/request-handler.js
Expand Up @@ -9,7 +9,7 @@ var peerId = Buffer.from('01234567890123456789')
function testRequestHandler (t, serverType) {
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 {
announce (params, cb) {
Expand All @@ -33,7 +33,7 @@ function testRequestHandler (t, serverType) {
var client1 = new Client({
infoHash: fixtures.alice.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand Down
4 changes: 2 additions & 2 deletions test/scrape.js
Expand Up @@ -14,7 +14,7 @@ function testSingle (t, serverType) {
var client = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881,
wrtc: {}
})
Expand Down Expand Up @@ -199,7 +199,7 @@ test('server: all info_hash scrape (manual http request)', function (t) {
var client = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881
})
client.on('error', function (err) { t.error(err) })
Expand Down
16 changes: 8 additions & 8 deletions test/server.js
Expand Up @@ -19,7 +19,7 @@ function serverTest (t, serverType, serverFamily) {
: '127.0.0.1'

var opts = {
serverType: serverType
serverType
}

common.createServer(t, opts, function (server) {
Expand All @@ -29,11 +29,11 @@ function serverTest (t, serverType, serverFamily) {
var announceUrl = serverType + '://' + hostname + ':' + port + '/announce'

var client1 = new Client({
infoHash: infoHash,
infoHash,
announce: [announceUrl],
peerId: peerId,
peerId,
port: 6881,
wrtc: wrtc
wrtc
})
if (serverType === 'ws') common.mockWebsocketTracker(client1)

Expand Down Expand Up @@ -89,11 +89,11 @@ function serverTest (t, serverType, serverFamily) {
t.equal(typeof data.downloaded, 'number')

var client2 = new Client({
infoHash: infoHash,
infoHash,
announce: [announceUrl],
peerId: peerId2,
port: 6882,
wrtc: wrtc
wrtc
})
if (serverType === 'ws') common.mockWebsocketTracker(client2)

Expand All @@ -109,11 +109,11 @@ function serverTest (t, serverType, serverFamily) {
t.equal(data.incomplete, 1)

var client3 = new Client({
infoHash: infoHash,
infoHash,
announce: [announceUrl],
peerId: peerId3,
port: 6880,
wrtc: wrtc
wrtc
})
if (serverType === 'ws') common.mockWebsocketTracker(client3)

Expand Down
2 changes: 1 addition & 1 deletion test/stats.js
Expand Up @@ -120,7 +120,7 @@ test('server: get leecher stats.json', function (t) {
var client = new Client({
infoHash: fixtures.leaves.parsedTorrent.infoHash,
announce: announceUrl,
peerId: peerId,
peerId,
port: 6881
})
client.on('error', function (err) { t.error(err) })
Expand Down