diff --git a/.gitignore b/.gitignore index ca99152..d450ee1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ coverage .nyc_output docs dist +.coverage \ No newline at end of file diff --git a/package.json b/package.json index e05c249..1426e5e 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,7 @@ "@multiformats/multiaddr-to-uri": "^9.0.2", "abortable-iterator": "^4.0.2", "err-code": "^3.0.1", - "it-ws": "^5.0.0", + "it-ws": "^5.0.6", "p-defer": "^4.0.0", "p-timeout": "^6.0.0", "wherearewe": "^2.0.1" diff --git a/test/node.ts b/test/node.ts index 9af037d..b3f2491 100644 --- a/test/node.ts +++ b/test/node.ts @@ -2,6 +2,7 @@ /* eslint max-nested-callbacks: ["error", 6] */ import https from 'https' +import http from 'http' import fs from 'fs' import { expect } from 'aegir/chai' import { multiaddr } from '@multiformats/multiaddr' @@ -102,6 +103,14 @@ describe('listen', () => { void listener.listen(ma) }) + it('should error on starting two listeners on same address', async () => { + listener = ws.createListener({ upgrader }) + const dumbServer = http.createServer() + await new Promise(resolve => dumbServer.listen(ma.toOptions().port, resolve)) + await expect(listener.listen(ma)).to.eventually.rejectedWith('listen EADDRINUSE') + await new Promise(resolve => dumbServer.close(() => resolve())) + }) + it('listen, check for the close event', (done) => { const listener = ws.createListener({ upgrader })