import * as magnetUtil from 'magnet-uri'
import 'mocha'
-import { getVideo, killallServers, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils'
+import { getVideo, killallServers, reRunServer, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils'
import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index'
import { VideoDetails } from '../../../../shared/models/videos'
import * as WebTorrent from 'webtorrent'
}
})
- it('Should return an error when adding an incorrect infohash', done => {
+ it('Should return an error when adding an incorrect infohash', function (done) {
this.timeout(10000)
const webtorrent = new WebTorrent()
torrent.on('done', () => done(new Error('No error on infohash')))
})
- it('Should succeed with the correct infohash', done => {
+ it('Should succeed with the correct infohash', function (done) {
this.timeout(10000)
const webtorrent = new WebTorrent()
torrent.on('done', done)
})
+ it('Should disable the tracker', function (done) {
+ this.timeout(20000)
+
+ killallServers([ server ])
+ reRunServer(server, { tracker: { enabled: false } })
+ .then(() => {
+ const webtorrent = new WebTorrent()
+
+ const torrent = webtorrent.add(goodMagnet)
+
+ torrent.on('error', done)
+ torrent.on('warning', warn => {
+ const message = typeof warn === 'string' ? warn : warn.message
+ if (message.indexOf('disabled ') !== -1) return done()
+ })
+
+ torrent.on('done', () => done(new Error('Tracker is enabled')))
+ })
+ })
+
after(async function () {
killallServers([ server ])
})