Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
actually fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 8, 2016
1 parent a6ba60a commit a81c328
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 30 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@
"stream-pair": "^1.0.3"
},
"dependencies": {
"async": "^2.0.0-rc.4",
"babel-runtime": "^6.6.1",
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
"ip-address": "^5.8.0",
"lodash.contains": "^2.4.3",
"multistream-select": "^0.6.5",
"multiaddr": "^1.4.0",
"multistream-select": "^0.6.5",
"peer-id": "^0.6.6",
"peer-info": "^0.6.2",
"protocol-buffers-stream": "^1.3.1"
"protocol-buffers-stream": "^1.3.1",
"run-parallel": "^1.1.6"
},
"aegir": {
"webpack": {
Expand Down
16 changes: 4 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

const async = require('async')
const multistream = require('multistream-select')
const identify = require('./identify')
const DuplexPassThrough = require('duplex-passthrough')
const contains = require('lodash.contains')
const util = require('util')
const EE = require('events').EventEmitter
const parallel = require('run-parallel')

exports = module.exports = Swarm

Expand Down Expand Up @@ -378,17 +378,9 @@ function Swarm (peerInfo) {
this.muxedConns[key].muxer.end()
})

async.each(
Object.keys(this.transports),
(key, cb) => {
// avoid unhandled error messages
this.transports[key].once('error', (err) => {
console.log('got error', err)
})
this.transports[key].close(cb)
},
callback
)
parallel(Object.keys(this.transports).map((key) => {
return (cb) => this.transports[key].close(cb)
}), callback)
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/01-transport-tcp.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect

const async = require('async')
const parallel = require('run-parallel')
const multiaddr = require('multiaddr')
const Peer = require('peer-info')
const Swarm = require('../src')
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('transport - tcp', function () {
})

it('close', (done) => {
async.parallel([
parallel([
(cb) => swarmA.transport.close('tcp', cb),
(cb) => swarmB.transport.close('tcp', cb)
], done)
Expand Down
4 changes: 2 additions & 2 deletions test/03-transport-websockets.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect

const async = require('async')
const parallel = require('run-parallel')
const multiaddr = require('multiaddr')
const Peer = require('peer-info')
const Swarm = require('../src')
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('transport - websockets', function () {
})

it('close', (done) => {
async.parallel([
parallel([
(cb) => swarmA.transport.close('ws', cb),
(cb) => swarmB.transport.close('ws', cb)
], done)
Expand Down
6 changes: 3 additions & 3 deletions test/04-muxing-multiplex.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect

const async = require('async')
const parallel = require('run-parallel')
const multiaddr = require('multiaddr')
const Peer = require('peer-info')
const Swarm = require('../src')
Expand Down Expand Up @@ -41,15 +41,15 @@ describe('stream muxing with multiplex (on TCP)', function () {
swarmB.transport.add('tcp', new TCP())
swarmC.transport.add('tcp', new TCP())

async.parallel([
parallel([
(cb) => swarmA.transport.listen('tcp', {}, null, cb),
(cb) => swarmB.transport.listen('tcp', {}, null, cb),
(cb) => swarmC.transport.listen('tcp', {}, null, cb)
], done)
})

after((done) => {
async.parallel([
parallel([
(cb) => swarmA.close(cb),
(cb) => swarmB.close(cb),
(cb) => swarmC.close(cb)
Expand Down
8 changes: 4 additions & 4 deletions test/05-muxing-spdy.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

const expect = require('chai').expect

const async = require('async')
const parallel = require('run-parallel')
const multiaddr = require('multiaddr')
const Peer = require('peer-info')
const Swarm = require('../src')
const TCP = require('libp2p-tcp')
const spdy = require('libp2p-spdy')

describe('stream muxing with spdy (on TCP)', function () {
this.timeout(20000)
this.timeout(60 * 1000)

var swarmA
var peerA
Expand Down Expand Up @@ -41,15 +41,15 @@ describe('stream muxing with spdy (on TCP)', function () {
swarmB.transport.add('tcp', new TCP())
swarmC.transport.add('tcp', new TCP())

async.parallel([
parallel([
(cb) => swarmA.transport.listen('tcp', {}, null, cb),
(cb) => swarmB.transport.listen('tcp', {}, null, cb),
(cb) => swarmC.transport.listen('tcp', {}, null, cb)
], done)
})

after((done) => {
async.parallel([
parallel([
(cb) => swarmA.close(cb),
(cb) => swarmB.close(cb),
(cb) => swarmC.close(cb)
Expand Down
4 changes: 2 additions & 2 deletions test/08-swarm-without-muxing.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect

const async = require('async')
const parallel = require('run-parallel')
const multiaddr = require('multiaddr')
const Peer = require('peer-info')
const Swarm = require('../src')
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('high level API - 1st without stream multiplexing (on TCP)', function (
})

after((done) => {
async.parallel([
parallel([
(cb) => swarmA.close(cb),
(cb) => swarmB.close(cb)
], done)
Expand Down
4 changes: 2 additions & 2 deletions test/09-swarm-with-muxing.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect

const async = require('async')
const parallel = require('run-parallel')
const multiaddr = require('multiaddr')
const Peer = require('peer-info')
const Swarm = require('../src')
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('high level API - with everything mixed all together!', function () {
})

after((done) => {
async.parallel([
parallel([
(cb) => swarmA.close(cb),
(cb) => swarmB.close(cb),
// (cb) => swarmC.close(cb),
Expand Down

0 comments on commit a81c328

Please sign in to comment.