mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-24 14:31:35 +00:00
fix: upgrader should not need muxers (#517)
* fix: upgrader should not need muxers * chore: address review * chore: apply suggestions from code review Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
@ -116,6 +116,35 @@ describe('Upgrader', () => {
|
||||
expect(result).to.eql([hello])
|
||||
})
|
||||
|
||||
it('should upgrade with only crypto', async () => {
|
||||
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer })
|
||||
|
||||
// No available muxers
|
||||
const muxers = new Map()
|
||||
sinon.stub(localUpgrader, 'muxers').value(muxers)
|
||||
sinon.stub(remoteUpgrader, 'muxers').value(muxers)
|
||||
|
||||
const cryptos = new Map([[Crypto.protocol, Crypto]])
|
||||
sinon.stub(localUpgrader, 'cryptos').value(cryptos)
|
||||
sinon.stub(remoteUpgrader, 'cryptos').value(cryptos)
|
||||
|
||||
const connections = await Promise.all([
|
||||
localUpgrader.upgradeOutbound(outbound),
|
||||
remoteUpgrader.upgradeInbound(inbound)
|
||||
])
|
||||
|
||||
expect(connections).to.have.length(2)
|
||||
|
||||
await expect(connections[0].newStream('/echo/1.0.0')).to.be.rejected()
|
||||
|
||||
// Verify the MultiaddrConnection close method is called
|
||||
sinon.spy(inbound, 'close')
|
||||
sinon.spy(outbound, 'close')
|
||||
await Promise.all(connections.map(conn => conn.close()))
|
||||
expect(inbound.close.callCount).to.equal(1)
|
||||
expect(outbound.close.callCount).to.equal(1)
|
||||
})
|
||||
|
||||
it('should use a private connection protector when provided', async () => {
|
||||
const { inbound, outbound } = mockMultiaddrConnPair({ addrs, remotePeer })
|
||||
|
||||
|
Reference in New Issue
Block a user