mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-13 01:01:23 +00:00
add multistream and muxer tests
This commit is contained in:
@ -20,9 +20,9 @@ b.on('error', function (err) {
|
|||||||
b.listen()
|
b.listen()
|
||||||
|
|
||||||
b.registerHandler('/ipfs/sparkles/1.2.3', function (stream) {
|
b.registerHandler('/ipfs/sparkles/1.2.3', function (stream) {
|
||||||
// if (err) {
|
// if (err) {
|
||||||
// return console.log(err)
|
// return console.log(err)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
console.log('woop got a stream')
|
console.log('woop got a stream')
|
||||||
})
|
})
|
||||||
|
@ -55,8 +55,8 @@ function Swarm () {
|
|||||||
// FOR IDENTIFY
|
// FOR IDENTIFY
|
||||||
self.emit('connection-unknown', conn)
|
self.emit('connection-unknown', conn)
|
||||||
|
|
||||||
// IDENTIFY DOES THIS FOR US
|
// IDENTIFY DOES THIS FOR US
|
||||||
// conn.on('close', function () { delete self.connections[conn.peerId] })
|
// conn.on('close', function () { delete self.connections[conn.peerId] })
|
||||||
})
|
})
|
||||||
}).listen(self.port, ready)
|
}).listen(self.port, ready)
|
||||||
errorUp(self, self.listener)
|
errorUp(self, self.listener)
|
||||||
|
@ -76,7 +76,6 @@ experiment('BASE', function () {
|
|||||||
*/
|
*/
|
||||||
experiment('IDENTIFY', function () {
|
experiment('IDENTIFY', function () {
|
||||||
test('Attach Identify, open a stream, see a peer update', function (done) {
|
test('Attach Identify, open a stream, see a peer update', function (done) {
|
||||||
|
|
||||||
swarmA.on('error', function (err) {
|
swarmA.on('error', function (err) {
|
||||||
console.log('A - ', err)
|
console.log('A - ', err)
|
||||||
})
|
})
|
||||||
@ -103,31 +102,31 @@ experiment('IDENTIFY', function () {
|
|||||||
identifyA.on('peer-update', function (answer) {})
|
identifyA.on('peer-update', function (answer) {})
|
||||||
}, 500)
|
}, 500)
|
||||||
})
|
})
|
||||||
/*
|
/*
|
||||||
test('Attach Identify, open a stream, reuse stream', function (done) {
|
test('Attach Identify, open a stream, reuse stream', function (done) {
|
||||||
var protocol = '/sparkles/3.3.3'
|
var protocol = '/sparkles/3.3.3'
|
||||||
|
|
||||||
var identifyA = new Identify(swarmA, peerA)
|
var identifyA = new Identify(swarmA, peerA)
|
||||||
var identifyB = new Identify(swarmB, peerB)
|
var identifyB = new Identify(swarmB, peerB)
|
||||||
|
|
||||||
swarmA.registerHandler(protocol, function (stream) {})
|
swarmA.registerHandler(protocol, function (stream) {})
|
||||||
swarmB.registerHandler(protocol, function (stream) {})
|
swarmB.registerHandler(protocol, function (stream) {})
|
||||||
|
|
||||||
swarmA.openStream(peerB, protocol, function theOTHER (err, stream) {
|
swarmA.openStream(peerB, protocol, function theOTHER (err, stream) {
|
||||||
expect(err).to.not.be.instanceof(Error)
|
expect(err).to.not.be.instanceof(Error)
|
||||||
})
|
|
||||||
|
|
||||||
identifyB.on('peer-update', function (answer) {
|
|
||||||
expect(Object.keys(swarmB.connections).length).to.equal(1)
|
|
||||||
swarmB.openStream(peerA, protocol, function theCALLBACK (err, stream) {
|
|
||||||
expect(err).to.not.be.instanceof(Error)
|
|
||||||
expect(Object.keys(swarmB.connections).length).to.equal(1)
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
identifyA.on('peer-update', function (answer) {})
|
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
|
identifyB.on('peer-update', function (answer) {
|
||||||
|
expect(Object.keys(swarmB.connections).length).to.equal(1)
|
||||||
|
swarmB.openStream(peerA, protocol, function theCALLBACK (err, stream) {
|
||||||
|
expect(err).to.not.be.instanceof(Error)
|
||||||
|
expect(Object.keys(swarmB.connections).length).to.equal(1)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
identifyA.on('peer-update', function (answer) {})
|
||||||
|
})
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
|
|
||||||
experiment('HARDNESS', function () {})
|
experiment('HARDNESS', function () {})
|
||||||
|
Reference in New Issue
Block a user