@@ -22,6 +22,7 @@ describe('CID', () => {
2222 const cid = new CID ( mhStr )
2323
2424 expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
25+ expect ( cid ) . to . have . property ( 'code' , 112 )
2526 expect ( cid ) . to . have . property ( 'version' , 0 )
2627 expect ( cid ) . to . have . property ( 'multihash' ) . that . eql ( multihash . fromB58String ( mhStr ) )
2728 expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -36,6 +37,7 @@ describe('CID', () => {
3637 const cid = new CID ( mh )
3738
3839 expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
40+ expect ( cid ) . to . have . property ( 'code' , 112 )
3941 expect ( cid ) . to . have . property ( 'version' , 0 )
4042 expect ( cid ) . to . have . property ( 'multihash' ) . that . eql ( mh )
4143 expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -47,6 +49,17 @@ describe('CID', () => {
4749 const cid = new CID ( 0 , 'dag-pb' , hash )
4850
4951 expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
52+ expect ( cid ) . to . have . property ( 'code' , 112 )
53+ expect ( cid ) . to . have . property ( 'version' , 0 )
54+ expect ( cid ) . to . have . property ( 'multihash' )
55+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
56+ } )
57+
58+ it ( 'create by parts (int codec)' , ( ) => {
59+ const cid = new CID ( 0 , 112 , hash )
60+
61+ expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
62+ expect ( cid ) . to . have . property ( 'code' , 112 )
5063 expect ( cid ) . to . have . property ( 'version' , 0 )
5164 expect ( cid ) . to . have . property ( 'multihash' )
5265 expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -110,6 +123,7 @@ describe('CID', () => {
110123 const cid = new CID ( cidStr )
111124
112125 expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
126+ expect ( cid ) . to . have . property ( 'code' , 112 )
113127 expect ( cid ) . to . have . property ( 'version' , 1 )
114128 expect ( cid ) . to . have . property ( 'multihash' )
115129 expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -124,6 +138,7 @@ describe('CID', () => {
124138 const cid = new CID ( cidBuf )
125139
126140 expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
141+ expect ( cid ) . to . have . property ( 'code' , 112 )
127142 expect ( cid ) . to . have . property ( 'version' , 1 )
128143 expect ( cid ) . to . have . property ( 'multihash' )
129144 expect ( cid ) . to . have . property ( 'multibaseName' , 'base32' )
@@ -137,6 +152,7 @@ describe('CID', () => {
137152 const cid = new CID ( peerIdStr )
138153
139154 expect ( cid ) . to . have . property ( 'codec' , 'libp2p-key' )
155+ expect ( cid ) . to . have . property ( 'code' , 114 )
140156 expect ( cid ) . to . have . property ( 'version' , 1 )
141157 expect ( cid ) . to . have . property ( 'multihash' )
142158 expect ( cid ) . to . have . property ( 'multibaseName' , 'base36' )
@@ -148,6 +164,7 @@ describe('CID', () => {
148164 const cid = new CID ( 1 , 'dag-cbor' , hash )
149165
150166 expect ( cid ) . to . have . property ( 'codec' , 'dag-cbor' )
167+ expect ( cid ) . to . have . property ( 'code' , 113 )
151168 expect ( cid ) . to . have . property ( 'version' , 1 )
152169 expect ( cid ) . to . have . property ( 'multihash' )
153170 expect ( cid ) . to . have . property ( 'multibaseName' , 'base32' )
@@ -158,6 +175,7 @@ describe('CID', () => {
158175 const cid2 = new CID ( cid1 . toBaseEncodedString ( ) )
159176
160177 expect ( cid1 ) . to . have . property ( 'codec' ) . that . eql ( cid2 . codec )
178+ expect ( cid1 ) . to . have . property ( 'code' ) . that . eql ( cid2 . code )
161179 expect ( cid1 ) . to . have . property ( 'version' ) . that . eql ( cid2 . version )
162180 expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( cid2 . multihash )
163181 expect ( cid1 ) . to . have . property ( 'multibaseName' ) . that . eql ( cid2 . multibaseName )
@@ -170,6 +188,7 @@ describe('CID', () => {
170188 const cid2 = new CID ( cid1 . toBaseEncodedString ( ) )
171189
172190 expect ( cid1 ) . to . have . property ( 'codec' , 'eth-block' )
191+ expect ( cid1 ) . to . have . property ( 'code' , 144 )
173192 expect ( cid1 ) . to . have . property ( 'version' , 1 )
174193 expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
175194 expect ( cid1 ) . to . have . property ( 'multibaseName' , 'base32' )
@@ -189,13 +208,15 @@ describe('CID', () => {
189208 const cid0 = new CID ( 0 , 'dag-pb' , mh )
190209
191210 expect ( cid0 ) . to . have . property ( 'codec' , 'dag-pb' )
211+ expect ( cid0 ) . to . have . property ( 'code' , 112 )
192212 expect ( cid0 ) . to . have . property ( 'version' , 0 )
193213 expect ( cid0 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
194214 expect ( cid0 . toBaseEncodedString ( ) ) . to . eql ( '161g3c' )
195215
196216 const cid1 = new CID ( 1 , 'dag-cbor' , mh )
197217
198218 expect ( cid1 ) . to . have . property ( 'codec' , 'dag-cbor' )
219+ expect ( cid1 ) . to . have . property ( 'code' , 113 )
199220 expect ( cid1 ) . to . have . property ( 'version' , 1 )
200221 expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
201222 expect ( cid1 . toBaseEncodedString ( ) ) . to . eql ( 'bafyqaa3bmjrq' )
0 commit comments