aboutsummaryrefslogtreecommitdiffhomepage
path: root/packages/tests/src/shared/tracker.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/tests/src/shared/tracker.ts')
-rw-r--r--packages/tests/src/shared/tracker.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/tests/src/shared/tracker.ts b/packages/tests/src/shared/tracker.ts
new file mode 100644
index 000000000..6ab430456
--- /dev/null
+++ b/packages/tests/src/shared/tracker.ts
@@ -0,0 +1,27 @@
1import { expect } from 'chai'
2import { sha1 } from '@peertube/peertube-node-utils'
3import { makeGetRequest } from '@peertube/peertube-server-commands'
4
5async 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
25export {
26 hlsInfohashExist
27}