From 31b6ddf86652502e0c96d77fa10861ce4af11aa4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Apr 2019 09:23:18 +0200 Subject: Add ability to disable tracker --- server/tests/api/server/tracker.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'server/tests/api') 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 ]) }) -- cgit v1.2.3