+ .then(() => server.run())
+ .then(() => {
+ const webtorrent = new WebTorrent()
+
+ const torrent = webtorrent.add(badMagnet)
+
+ torrent.on('error', done)
+ torrent.on('warning', warn => {
+ const message = typeof warn === 'string' ? warn : warn.message
+ if (message.includes('Unknown infoHash ')) return done()
+ })
+
+ torrent.on('done', () => done(new Error('No error on infohash')))
+ })
+ })
+
+ it('Should block the IP after the failed infohash', function (done) {
+ 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.includes('Unsupported tracker protocol')) return done()
+ })
+ })
+
+ after(async function () {
+ await cleanupTests([ server ])