]>
Commit | Line | Data |
---|---|---|
fb72d2e1 | 1 | import { expect } from 'chai' |
f304a158 | 2 | import { sha1 } from '@shared/extra-utils' |
c55e3d72 | 3 | import { makeGetRequest } from '@shared/server-commands' |
fb72d2e1 C |
4 | |
5 | async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) { | |
6 | const path = '/tracker/announce' | |
7 | ||
8 | const infohash = sha1(`2${masterPlaylistUrl}+V${fileNumber}`) | |
9 | ||
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() | |
13 | }) | |
14 | ||
15 | const res = await makeGetRequest({ | |
16 | url: serverUrl, | |
17 | path, | |
18 | rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`, | |
19 | expectedStatus: 200 | |
20 | }) | |
21 | ||
22 | expect(res.text).to.not.contain('failure') | |
23 | } | |
24 | ||
25 | export { | |
26 | hlsInfohashExist | |
27 | } |