feat: add libp2p.connections getter (#522)

* fix: make hangup accept what the API says it does

* feat: add libp2p.connections getter

* chore: fix typo
This commit is contained in:
Jacob Heun
2019-12-16 19:24:35 +01:00
parent 4ca481b869
commit 6445fda050
4 changed files with 62 additions and 9 deletions

View File

@ -296,6 +296,23 @@ describe('Dialing (direct, TCP)', () => {
expect(connection.stat.timeline.close).to.exist()
})
it('should be able to use hangup by address string to close connections', async () => {
libp2p = new Libp2p({
peerInfo,
modules: {
transport: [Transport],
streamMuxer: [Muxer],
connEncryption: [Crypto]
}
})
const connection = await libp2p.dial(`${remoteAddr.toString()}/p2p/${remotePeerInfo.id.toString()}`)
expect(connection).to.exist()
expect(connection.stat.timeline.close).to.not.exist()
await libp2p.hangUp(connection.remotePeer)
expect(connection.stat.timeline.close).to.exist()
})
it('should use the protectors when provided for connecting', async () => {
const protector = new Protector(swarmKeyBuffer)
libp2p = new Libp2p({