mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-18 11:41:21 +00:00
@ -185,7 +185,7 @@ describe('transports', () => {
|
||||
})
|
||||
|
||||
it('nodeA.hangUp nodeB using PeerId (third)', (done) => {
|
||||
nodeA.hangUp(nodeB.peerInfo.multiaddrs.toArray()[0], (err) => {
|
||||
nodeA.hangUp(nodeB.peerInfo.id, (err) => {
|
||||
expect(err).to.not.exist()
|
||||
setTimeout(check, 500)
|
||||
|
||||
@ -207,6 +207,51 @@ describe('transports', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('.dialFSM check conn and close', (done) => {
|
||||
nodeA.dialFSM(nodeB.peerInfo, (err, connFSM) => {
|
||||
expect(err).to.not.exist()
|
||||
|
||||
connFSM.once('muxed', () => {
|
||||
expect(nodeA._switch.muxedConns).to.have.any.keys(
|
||||
nodeB.peerInfo.id.toB58String()
|
||||
)
|
||||
|
||||
connFSM.once('error', done)
|
||||
connFSM.once('close', () => {
|
||||
// ensure the connection is closed
|
||||
expect(nodeA._switch.muxedConns).to.not.have.any.keys([
|
||||
nodeB.peerInfo.id.toB58String()
|
||||
])
|
||||
done()
|
||||
})
|
||||
|
||||
connFSM.close()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('.dialFSM with a protocol, do an echo and close', (done) => {
|
||||
nodeA.dialFSM(nodeB.peerInfo, '/echo/1.0.0', (err, connFSM) => {
|
||||
expect(err).to.not.exist()
|
||||
connFSM.once('connection', (conn) => {
|
||||
expect(nodeA._switch.muxedConns).to.have.all.keys([
|
||||
nodeB.peerInfo.id.toB58String()
|
||||
])
|
||||
tryEcho(conn, () => {
|
||||
connFSM.close()
|
||||
})
|
||||
})
|
||||
connFSM.once('error', done)
|
||||
connFSM.once('close', () => {
|
||||
// ensure the connection is closed
|
||||
expect(nodeA._switch.muxedConns).to.not.have.any.keys([
|
||||
nodeB.peerInfo.id.toB58String()
|
||||
])
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('TCP + WebSockets', () => {
|
||||
|
Reference in New Issue
Block a user