Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('Command line: webtorrent downloadmeta ', t => {
t.plan(2)
const fixturesPath = path.join(path.dirname(require.resolve('webtorrent-fixtures')), 'fixtures')
cp.exec(`${CMD} downloadmeta '${fixtures.sintel.magnetURI}' --out ${fixturesPath}`, (err, data) => {
t.error(err)
const parsedTorrent = parseTorrent(fs.readFileSync(`${fixturesPath}/${fixtures.sintel.parsedTorrent.infoHash}.torrent`))
// Sintel torrent file contain two fields not availaible from the DHT
const expectedTorrent = fixtures.sintel.parsedTorrent
delete expectedTorrent.created
delete expectedTorrent.createdBy
t.deepEqual(parsedTorrent, expectedTorrent)
})
})
cp.exec(`${CMD} downloadmeta '${fixtures.sintel.magnetURI}' --out ${fixturesPath}`, (err, data) => {
t.error(err)
const parsedTorrent = parseTorrent(fs.readFileSync(`${fixturesPath}/${fixtures.sintel.parsedTorrent.infoHash}.torrent`))
// Sintel torrent file contain two fields not availaible from the DHT
const expectedTorrent = fixtures.sintel.parsedTorrent
delete expectedTorrent.created
delete expectedTorrent.createdBy
t.deepEqual(parsedTorrent, expectedTorrent)
})
})
common.createServer(t, serverType, function (server, announceUrl) {
var client = new Client({
infoHash: fixtures.sintel.parsedTorrent.infoHash,
peerId: peerId,
port: 6881,
announce: announceUrl,
wrtc: {}
})
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')
client.update()