Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
fix: transport should not handle connection if upgradeInbound throws
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Dec 20, 2019
1 parent 2803e64 commit 7bb5448
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/transport/tests/listen-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ module.exports = (common) => {
expect(upgradeSpy.callCount).to.equal(2)
})

it('should not handle connection if upgradeInbound throws', async () => {
sinon.stub(upgrader, 'upgradeInbound').throws()

const listener = transport.createListener(() => {
throw new Error('should not handle the connection if upgradeInbound throws')
})

// Listen
await listener.listen(addrs[0])

// Create a connection to the listener
const socket = await transport.dial(addrs[0])

await socket.close()
await listener.close()
})

describe('events', () => {
it('connection', (done) => {
const upgradeSpy = sinon.spy(upgrader, 'upgradeInbound')
Expand Down

0 comments on commit 7bb5448

Please sign in to comment.