aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/server/tracker.ts26
1 files changed, 23 insertions, 3 deletions
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 @@
2 2
3import * as magnetUtil from 'magnet-uri' 3import * as magnetUtil from 'magnet-uri'
4import 'mocha' 4import 'mocha'
5import { getVideo, killallServers, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils' 5import { getVideo, killallServers, reRunServer, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils'
6import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index' 6import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index'
7import { VideoDetails } from '../../../../shared/models/videos' 7import { VideoDetails } from '../../../../shared/models/videos'
8import * as WebTorrent from 'webtorrent' 8import * as WebTorrent from 'webtorrent'
@@ -34,7 +34,7 @@ describe('Test tracker', function () {
34 } 34 }
35 }) 35 })
36 36
37 it('Should return an error when adding an incorrect infohash', done => { 37 it('Should return an error when adding an incorrect infohash', function (done) {
38 this.timeout(10000) 38 this.timeout(10000)
39 const webtorrent = new WebTorrent() 39 const webtorrent = new WebTorrent()
40 40
@@ -49,7 +49,7 @@ describe('Test tracker', function () {
49 torrent.on('done', () => done(new Error('No error on infohash'))) 49 torrent.on('done', () => done(new Error('No error on infohash')))
50 }) 50 })
51 51
52 it('Should succeed with the correct infohash', done => { 52 it('Should succeed with the correct infohash', function (done) {
53 this.timeout(10000) 53 this.timeout(10000)
54 const webtorrent = new WebTorrent() 54 const webtorrent = new WebTorrent()
55 55
@@ -64,6 +64,26 @@ describe('Test tracker', function () {
64 torrent.on('done', done) 64 torrent.on('done', done)
65 }) 65 })
66 66
67 it('Should disable the tracker', function (done) {
68 this.timeout(20000)
69
70 killallServers([ server ])
71 reRunServer(server, { tracker: { enabled: false } })
72 .then(() => {
73 const webtorrent = new WebTorrent()
74
75 const torrent = webtorrent.add(goodMagnet)
76
77 torrent.on('error', done)
78 torrent.on('warning', warn => {
79 const message = typeof warn === 'string' ? warn : warn.message
80 if (message.indexOf('disabled ') !== -1) return done()
81 })
82
83 torrent.on('done', () => done(new Error('Tracker is enabled')))
84 })
85 })
86
67 after(async function () { 87 after(async function () {
68 killallServers([ server ]) 88 killallServers([ server ])
69 }) 89 })