X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Ftracker.ts;h=41803aef133d61893458bdbcbdd6823ad80aa685;hb=31b6ddf86652502e0c96d77fa10861ce4af11aa4;hp=25ca00029bc9fc8d94731b27be1b9daf257f2257;hpb=88108880bbdba473cfe36ecbebc1c3c4f972e102;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts index 25ca00029..41803aef1 100644 --- a/server/tests/api/server/tracker.ts +++ b/server/tests/api/server/tracker.ts @@ -2,7 +2,7 @@ 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' @@ -34,7 +34,7 @@ describe('Test tracker', function () { } }) - 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() @@ -49,7 +49,7 @@ describe('Test tracker', function () { 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() @@ -64,6 +64,26 @@ describe('Test tracker', function () { 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 ]) })