Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests; misc fixes #532

Merged
merged 9 commits into from Dec 18, 2015
Prev

test: port blocklist-dht to new style

  • Loading branch information
feross committed Dec 17, 2015
commit 5d67f54f18dd5c581c48c5995cc0e8a37abe9e05
@@ -1,18 +1,10 @@
var auto = require('run-auto')
var common = require('./common')
var DHT = require('bittorrent-dht/server')
var fs = require('fs')
var networkAddress = require('network-address')
var parseTorrent = require('parse-torrent')
var path = require('path')
var test = require('tape')
var WebTorrent = require('../')

var leavesTorrent = fs.readFileSync(path.resolve(__dirname, 'torrents', 'leaves.torrent'))
var leavesParsed = parseTorrent(leavesTorrent)

// remove trackers from .torrent file
leavesParsed.announce = []

test('blocklist blocks peers discovered via DHT', function (t) {
t.plan(8)

@@ -37,7 +29,7 @@ test('blocklist blocks peers discovered via DHT', function (t) {
client1.on('error', function (err) { t.fail(err) })
client1.on('warning', function (err) { t.fail(err) })

var torrent1 = client1.add(leavesParsed)
var torrent1 = client1.add(common.leaves.parsedTorrent)

torrent1.on('peer', function () {
t.fail('client1 should not find any peers')
@@ -75,7 +67,7 @@ test('blocklist blocks peers discovered via DHT', function (t) {
client2.on('error', function (err) { t.fail(err) })
client2.on('warning', function (err) { t.fail(err) })

var torrent2 = client2.add(leavesParsed)
var torrent2 = client2.add(common.leaves.parsedTorrent)

torrent2.on('blockedPeer', function () {
t.pass('client2 blocked connection to client1')
@@ -94,14 +86,14 @@ test('blocklist blocks peers discovered via DHT', function (t) {
}, function (err, r) {
if (err) throw err

dhtServer.destroy(function () {
t.pass('dht server destroyed')
dhtServer.destroy(function (err) {
t.error(err, 'dht server destroyed')
})
r.client1.destroy(function () {
t.pass('client1 destroyed')
r.client1.destroy(function (err) {
t.error(err, 'client1 destroyed')
})
r.client2.destroy(function () {
t.pass('client2 destroyed')
r.client2.destroy(function (err) {
t.error(err, 'client2 destroyed')
})
})
})
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.