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",
|
"code": "^1.4.1",
|
||||||
"lab": "^5.13.0",
|
"lab": "^5.13.0",
|
||||||
"precommit-hook": "^3.0.0",
|
"precommit-hook": "^3.0.0",
|
||||||
|
"sinon": "^1.15.4",
|
||||||
"standard": "^4.5.2",
|
"standard": "^4.5.2",
|
||||||
"stream-pair": "^1.0.3"
|
"stream-pair": "^1.0.3"
|
||||||
},
|
},
|
||||||
|
@ -150,9 +150,9 @@ function Swarm () {
|
|||||||
if (number === 0) { cb() }
|
if (number === 0) { cb() }
|
||||||
var c = new Counter(number, cb)
|
var c = new Counter(number, cb)
|
||||||
|
|
||||||
keys.map(function (key) {
|
keys.forEach(function (key) {
|
||||||
c.hit()
|
|
||||||
self.connections[key].conn.end()
|
self.connections[key].conn.end()
|
||||||
|
c.hit()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
var Lab = require('lab')
|
var Lab = require('lab')
|
||||||
var Code = require('code')
|
var Code = require('code')
|
||||||
|
var sinon = require('sinon')
|
||||||
var lab = exports.lab = Lab.script()
|
var lab = exports.lab = Lab.script()
|
||||||
|
|
||||||
var experiment = lab.experiment
|
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 () {
|
experiment('BASE', function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user