mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-29 02:11:18 +00:00
Fix swarm.closeConns
This commit is contained in:
parent
a73066b10b
commit
f1d796f47b
@ -31,6 +31,7 @@
|
||||
"code": "^1.4.1",
|
||||
"lab": "^5.13.0",
|
||||
"precommit-hook": "^3.0.0",
|
||||
"sinon": "^1.15.4",
|
||||
"standard": "^4.5.2",
|
||||
"stream-pair": "^1.0.3"
|
||||
},
|
||||
|
@ -150,9 +150,9 @@ function Swarm () {
|
||||
if (number === 0) { cb() }
|
||||
var c = new Counter(number, cb)
|
||||
|
||||
keys.map(function (key) {
|
||||
c.hit()
|
||||
keys.forEach(function (key) {
|
||||
self.connections[key].conn.end()
|
||||
c.hit()
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
var Lab = require('lab')
|
||||
var Code = require('code')
|
||||
var sinon = require('sinon')
|
||||
var lab = exports.lab = Lab.script()
|
||||
|
||||
var experiment = lab.experiment
|
||||
@ -85,6 +86,19 @@ experiment('BASICS', function () {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
experiment('Swarm.closeConns', function () {
|
||||
test('calls end on all connections', function (done) {
|
||||
swarmA.openConnection(peerB, function () {
|
||||
var key = Object.keys(swarmA.connections)[0]
|
||||
sinon.spy(swarmA.connections[key].conn, 'end')
|
||||
swarmA.closeConns(function () {
|
||||
expect(swarmA.connections[key].conn.end.called).to.be.equal(true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
experiment('BASE', function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user