From a9af6858615178907ad079877bda730b22efa0a6 Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Wed, 25 Jan 2023 14:23:04 -0800 Subject: [PATCH 1/3] Add TLS to protocols-table --- src/protocols-table.ts | 1 + test/index.spec.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/protocols-table.ts b/src/protocols-table.ts index 1334a28c..b78614e6 100644 --- a/src/protocols-table.ts +++ b/src/protocols-table.ts @@ -35,6 +35,7 @@ export const table: Array<[number, number, string, boolean?, boolean?]> = [ [444, 96, 'onion'], [445, 296, 'onion3'], [446, V, 'garlic64'], + [448, 0, 'tls'], [460, 0, 'quic'], [461, 0, 'quic-v1'], [465, 0, 'webtransport'], diff --git a/test/index.spec.ts b/test/index.spec.ts index 24423f08..0f457819 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -424,6 +424,13 @@ describe('variants', () => { expect(addr.toString()).to.equal(str.replace('/ipfs/', '/p2p/')) }) + it('tls', () => { + const str = '/ip4/127.0.0.1/tcp/9090/tls/ws' + const addr = multiaddr(str) + expect(addr).to.have.property('bytes') + expect(addr.toString()).to.equal(str) + }) + it('onion', () => { const str = '/onion/timaq4ygg2iegci7:1234' const addr = multiaddr(str) @@ -1058,3 +1065,10 @@ describe('helpers', () => { }) }) }) + +describe("unknown protocols", () => { + it("throws an error", () => { + const str = '/ip4/127.0.0.1/unknown' + expect(() => multiaddr(str)).to.throw() + }) +}) \ No newline at end of file From cd86b534d96265e87729a3477a96904322bdee79 Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Wed, 25 Jan 2023 15:52:22 -0800 Subject: [PATCH 2/3] lint fix --- test/index.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/index.spec.ts b/test/index.spec.ts index 0f457819..57d59cc3 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -1066,9 +1066,9 @@ describe('helpers', () => { }) }) -describe("unknown protocols", () => { - it("throws an error", () => { +describe('unknown protocols', () => { + it('throws an error', () => { const str = '/ip4/127.0.0.1/unknown' expect(() => multiaddr(str)).to.throw() }) -}) \ No newline at end of file +}) From a2d727d850f47a6a32ee1e1186ed2d1750280b9a Mon Sep 17 00:00:00 2001 From: Marco Munizaga Date: Mon, 30 Jan 2023 09:46:55 -0800 Subject: [PATCH 3/3] Include error messsage expectation --- test/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/index.spec.ts b/test/index.spec.ts index 57d59cc3..21510b21 100644 --- a/test/index.spec.ts +++ b/test/index.spec.ts @@ -1069,6 +1069,6 @@ describe('helpers', () => { describe('unknown protocols', () => { it('throws an error', () => { const str = '/ip4/127.0.0.1/unknown' - expect(() => multiaddr(str)).to.throw() + expect(() => multiaddr(str)).to.throw('no protocol with name: unknown') }) })