Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ Client.scrape = function (opts, cb) {

var client = new Client(clientOpts)
client.once('error', cb)
client.once('warning', cb)

var len = Array.isArray(opts.infoHash) ? opts.infoHash.length : 1
var results = {}
Expand Down
28 changes: 28 additions & 0 deletions test/scrape.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,34 @@ test('ws: scrape using Client.scrape static method', function (t) {
clientScrapeStatic(t, 'ws')
})

// Ensure the callback function gets called when an invalid url is passed
function clientScrapeStaticInvalid (t, serverType) {
var announceUrl = serverType + '://invalid.lol'
if (serverType === 'http') announceUrl += '/announce'

var client = Client.scrape({
announce: announceUrl,
infoHash: fixtures.leaves.parsedTorrent.infoHash,
wrtc: {}
}, function (err, data) {
t.ok(err instanceof Error)
t.end()
})
if (serverType === 'ws') common.mockWebsocketTracker(client)
}

test.only('http: scrape using Client.scrape static method (invalid url)', function (t) {
clientScrapeStaticInvalid(t, 'http')
})

test('udp: scrape using Client.scrape static method (invalid url)', function (t) {
clientScrapeStaticInvalid(t, 'udp')
})

test('ws: scrape using Client.scrape static method (invalid url)', function (t) {
clientScrapeStaticInvalid(t, 'ws')
})

function clientScrapeMulti (t, serverType) {
var infoHash1 = fixtures.leaves.parsedTorrent.infoHash
var infoHash2 = fixtures.alice.parsedTorrent.infoHash
Expand Down