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

Deprecate bittorrent-swarm, inline into webtorrent #704

Merged
merged 9 commits into from Mar 29, 2016

Remove `portfinder` dependency

  • Loading branch information
feross committed Mar 29, 2016
commit 66069d90e6c349093a026cd4a283a3703146ea75
@@ -78,7 +78,6 @@
"electron-prebuilt": "^0.37.2",
"finalhandler": "^0.4.0",
"network-address": "^1.1.0",
"portfinder": "^1.0.0",
"run-series": "^1.0.2",
"serve-static": "^1.9.3",
"standard": "^6.0.1",
@@ -1,5 +1,4 @@
var hat = require('hat')
var portfinder = require('portfinder')
var Swarm = require('../../lib/swarm')
var test = require('tape')

@@ -8,35 +7,19 @@ var infoHash2 = 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa37'
var peerId = new Buffer('-WW0001-' + hat(48), 'utf8').toString('hex')
var peerId2 = new Buffer('-WW0001-' + hat(48), 'utf8').toString('hex')

test('swarm listen (explicit port)', function (t) {
t.plan(1)

var swarm = new Swarm(infoHash, peerId)
portfinder.getPort(function (err, port) {
if (err) throw err
swarm.listen(port)
swarm.on('listening', function () {
t.equal(port, swarm.address().port)
swarm.destroy()
})
})
})

test('two swarms listen on same port (explicit)', function (t) {
test('two swarms listen on same port', function (t) {
t.plan(2)

var swarm1 = new Swarm(infoHash, peerId)
portfinder.getPort(function (err, port) {
if (err) throw err
swarm1.listen(port, function () {
t.equal(swarm1.address().port, port, 'listened on requested port')
swarm1.listen(function () {
var port = swarm1.address().port
t.ok(typeof port === 'number' && port !== 0)

var swarm2 = new Swarm(infoHash2, peerId)
swarm2.listen(port, function () {
t.equal(swarm2.address().port, port, 'listened on requested port')
swarm1.destroy()
swarm2.destroy()
})
var swarm2 = new Swarm(infoHash2, peerId)
swarm2.listen(port, function () {
t.equal(swarm2.address().port, port, 'listened on requested port')
swarm1.destroy()
swarm2.destroy()
})
})
})
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.