aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/tracker.ts49
1 files changed, 34 insertions, 15 deletions
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts
index 5b56a83bb..4b86e0b90 100644
--- a/server/tests/api/server/tracker.ts
+++ b/server/tests/api/server/tracker.ts
@@ -40,21 +40,6 @@ describe('Test tracker', function () {
40 } 40 }
41 }) 41 })
42 42
43 it('Should return an error when adding an incorrect infohash', function (done) {
44 this.timeout(10000)
45 const webtorrent = new WebTorrent()
46
47 const torrent = webtorrent.add(badMagnet)
48
49 torrent.on('error', done)
50 torrent.on('warning', warn => {
51 const message = typeof warn === 'string' ? warn : warn.message
52 if (message.includes('Unknown infoHash ')) return done()
53 })
54
55 torrent.on('done', () => done(new Error('No error on infohash')))
56 })
57
58 it('Should succeed with the correct infohash', function (done) { 43 it('Should succeed with the correct infohash', function (done) {
59 this.timeout(10000) 44 this.timeout(10000)
60 const webtorrent = new WebTorrent() 45 const webtorrent = new WebTorrent()
@@ -76,6 +61,7 @@ describe('Test tracker', function () {
76 const errCb = () => done(new Error('Tracker is enabled')) 61 const errCb = () => done(new Error('Tracker is enabled'))
77 62
78 killallServers([ server ]) 63 killallServers([ server ])
64
79 reRunServer(server, { tracker: { enabled: false } }) 65 reRunServer(server, { tracker: { enabled: false } })
80 .then(() => { 66 .then(() => {
81 const webtorrent = new WebTorrent() 67 const webtorrent = new WebTorrent()
@@ -96,6 +82,39 @@ describe('Test tracker', function () {
96 }) 82 })
97 }) 83 })
98 84
85 it('Should return an error when adding an incorrect infohash', function (done) {
86 this.timeout(20000)
87
88 killallServers([ server ])
89
90 reRunServer(server)
91 .then(() => {
92 const webtorrent = new WebTorrent()
93
94 const torrent = webtorrent.add(badMagnet)
95
96 torrent.on('error', done)
97 torrent.on('warning', warn => {
98 const message = typeof warn === 'string' ? warn : warn.message
99 if (message.includes('Unknown infoHash ')) return done()
100 })
101
102 torrent.on('done', () => done(new Error('No error on infohash')))
103 })
104 })
105
106 it('Should block the IP after the failed infohash', function (done) {
107 const webtorrent = new WebTorrent()
108
109 const torrent = webtorrent.add(goodMagnet)
110
111 torrent.on('error', done)
112 torrent.on('warning', warn => {
113 const message = typeof warn === 'string' ? warn : warn.message
114 if (message.includes('Unsupported tracker protocol')) return done()
115 })
116 })
117
99 after(async function () { 118 after(async function () {
100 await cleanupTests([ server ]) 119 await cleanupTests([ server ])
101 }) 120 })