1 import { expect } from 'chai'
2 import { sha1 } from '@shared/extra-utils'
3 import { makeGetRequest } from '@shared/server-commands'
5 async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) {
6 const path = '/tracker/announce'
8 const infohash = sha1(`2${masterPlaylistUrl}+V${fileNumber}`)
10 // From bittorrent-tracker
11 const infohashBinary = escape(Buffer.from(infohash, 'hex').toString('binary')).replace(/[@*/+]/g, function (char) {
12 return '%' + char.charCodeAt(0).toString(16).toUpperCase()
15 const res = await makeGetRequest({
18 rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`,
22 expect(res.text).to.not.contain('failure')