06aad80165
Many files from the `shared` folder were importing files from the `server` folder. When attempting to use Typescript project references to describe dependencies, it highlighted a circular dependency beetween `shared` <-> `server`. The Typescript project forbid such usages. Using project references greatly improve performance by rebuilding only the updated project and not all source files. > see https://www.typescriptlang.org/docs/handbook/project-references.html
27 lines
803 B
TypeScript
27 lines
803 B
TypeScript
import { expect } from 'chai'
|
|
import { sha1 } from '@shared/core-utils/crypto'
|
|
import { makeGetRequest } from '../requests'
|
|
|
|
async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) {
|
|
const path = '/tracker/announce'
|
|
|
|
const infohash = sha1(`2${masterPlaylistUrl}+V${fileNumber}`)
|
|
|
|
// From bittorrent-tracker
|
|
const infohashBinary = escape(Buffer.from(infohash, 'hex').toString('binary')).replace(/[@*/+]/g, function (char) {
|
|
return '%' + char.charCodeAt(0).toString(16).toUpperCase()
|
|
})
|
|
|
|
const res = await makeGetRequest({
|
|
url: serverUrl,
|
|
path,
|
|
rawQuery: `peer_id=-WW0105-NkvYO/egUAr4&info_hash=${infohashBinary}&port=42100`,
|
|
expectedStatus: 200
|
|
})
|
|
|
|
expect(res.text).to.not.contain('failure')
|
|
}
|
|
|
|
export {
|
|
hlsInfohashExist
|
|
}
|