From 4e30a27a1649e95cd3401af66d532863be7e2f88 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Thu, 19 Sep 2019 11:45:29 +0200 Subject: [PATCH] test: add test for ambiguous codecs The codec `ipfs` and `p2p` both are assigned to `0x01a5`, where `ipfs` is the deprecated name. Make sure that we resolve to `p2p` if that number is used as input. --- test/multicodec.spec.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/multicodec.spec.js b/test/multicodec.spec.js index 2c7917c..6b846e2 100644 --- a/test/multicodec.spec.js +++ b/test/multicodec.spec.js @@ -78,6 +78,11 @@ describe('multicodec', () => { expect(multicodec.print[multicodec.BLAKE2B_8]).to.eql('blake2b-8') }) + it('returns p2p when 0x01a5 is used', () => { + // `ipfs` and `p2p` are assigned to `0x01a5`, `ipfs` is deprecated + expect(multicodec.print[0x01a5]).to.eql('p2p') + }) + it('throws error on unknown codec name when getting the code', () => { expect(() => { multicodec.getCodeVarint('this-codec-doesnt-exist')