1 /* tslint:disable:no-unused-expression */
4 import * as chai from 'chai'
5 const expect = chai.expect
16 setAccessTokensToServers,
22 describe('Test update host scripts', function () {
23 let server: ServerInfo
25 before(async function () {
30 const overrideConfig = {
35 // Run server 2 to have transcoding enabled
36 server = await runServer(2, overrideConfig)
37 await setAccessTokensToServers([ server ])
39 // Upload two videos for our needs
40 const videoAttributes = {}
41 await uploadVideo(server.url, server.accessToken, videoAttributes)
42 await uploadVideo(server.url, server.accessToken, videoAttributes)
46 it('Should update torrent hosts', async function () {
49 killallServers([ server ])
50 // Run server with standard configuration
51 server = await runServer(2)
53 const env = getEnvCli(server)
54 await execCLI(`${env} npm run update-host`)
56 const res = await getVideosList(server.url)
57 const videos = res.body.data
58 expect(videos).to.have.lengthOf(2)
60 for (const video of videos) {
61 const res2 = await getVideo(server.url, video.id)
62 const videoDetails = res2.body
64 expect(videoDetails.files).to.have.lengthOf(4)
66 for (const file of videoDetails.files) {
67 expect(file.magnetUri).to.contain('localhost%3A9002%2Ftracker%2Fsocket')
68 expect(file.magnetUri).to.contain('localhost%3A9002%2Fstatic%2Fwebseed%2F')
70 const torrent = await parseTorrentVideo(server, videoDetails.uuid, file.resolution)
71 const announceWS = torrent.announce.find(a => a === 'ws://localhost:9002/tracker/socket')
72 expect(announceWS).to.not.be.undefined
74 const announceHttp = torrent.announce.find(a => a === 'http://localhost:9002/tracker/announce')
75 expect(announceHttp).to.not.be.undefined
77 expect(torrent.urlList[0]).to.contain('http://localhost:9002/static/webseed')
82 after(async function () {
83 killallServers([ server ])
85 // Keep the logs if the test failed