@@ -22,6 +22,7 @@ describe('CID', () => {
22
22
const cid = new CID ( mhStr )
23
23
24
24
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
25
+ expect ( cid ) . to . have . property ( 'code' , 112 )
25
26
expect ( cid ) . to . have . property ( 'version' , 0 )
26
27
expect ( cid ) . to . have . property ( 'multihash' ) . that . eql ( multihash . fromB58String ( mhStr ) )
27
28
expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -36,6 +37,7 @@ describe('CID', () => {
36
37
const cid = new CID ( mh )
37
38
38
39
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
40
+ expect ( cid ) . to . have . property ( 'code' , 112 )
39
41
expect ( cid ) . to . have . property ( 'version' , 0 )
40
42
expect ( cid ) . to . have . property ( 'multihash' ) . that . eql ( mh )
41
43
expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -47,6 +49,17 @@ describe('CID', () => {
47
49
const cid = new CID ( 0 , 'dag-pb' , hash )
48
50
49
51
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 )
50
63
expect ( cid ) . to . have . property ( 'version' , 0 )
51
64
expect ( cid ) . to . have . property ( 'multihash' )
52
65
expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -110,6 +123,7 @@ describe('CID', () => {
110
123
const cid = new CID ( cidStr )
111
124
112
125
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
126
+ expect ( cid ) . to . have . property ( 'code' , 112 )
113
127
expect ( cid ) . to . have . property ( 'version' , 1 )
114
128
expect ( cid ) . to . have . property ( 'multihash' )
115
129
expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
@@ -124,6 +138,7 @@ describe('CID', () => {
124
138
const cid = new CID ( cidBuf )
125
139
126
140
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
141
+ expect ( cid ) . to . have . property ( 'code' , 112 )
127
142
expect ( cid ) . to . have . property ( 'version' , 1 )
128
143
expect ( cid ) . to . have . property ( 'multihash' )
129
144
expect ( cid ) . to . have . property ( 'multibaseName' , 'base32' )
@@ -137,6 +152,7 @@ describe('CID', () => {
137
152
const cid = new CID ( peerIdStr )
138
153
139
154
expect ( cid ) . to . have . property ( 'codec' , 'libp2p-key' )
155
+ expect ( cid ) . to . have . property ( 'code' , 114 )
140
156
expect ( cid ) . to . have . property ( 'version' , 1 )
141
157
expect ( cid ) . to . have . property ( 'multihash' )
142
158
expect ( cid ) . to . have . property ( 'multibaseName' , 'base36' )
@@ -148,6 +164,7 @@ describe('CID', () => {
148
164
const cid = new CID ( 1 , 'dag-cbor' , hash )
149
165
150
166
expect ( cid ) . to . have . property ( 'codec' , 'dag-cbor' )
167
+ expect ( cid ) . to . have . property ( 'code' , 113 )
151
168
expect ( cid ) . to . have . property ( 'version' , 1 )
152
169
expect ( cid ) . to . have . property ( 'multihash' )
153
170
expect ( cid ) . to . have . property ( 'multibaseName' , 'base32' )
@@ -158,6 +175,7 @@ describe('CID', () => {
158
175
const cid2 = new CID ( cid1 . toBaseEncodedString ( ) )
159
176
160
177
expect ( cid1 ) . to . have . property ( 'codec' ) . that . eql ( cid2 . codec )
178
+ expect ( cid1 ) . to . have . property ( 'code' ) . that . eql ( cid2 . code )
161
179
expect ( cid1 ) . to . have . property ( 'version' ) . that . eql ( cid2 . version )
162
180
expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( cid2 . multihash )
163
181
expect ( cid1 ) . to . have . property ( 'multibaseName' ) . that . eql ( cid2 . multibaseName )
@@ -170,6 +188,7 @@ describe('CID', () => {
170
188
const cid2 = new CID ( cid1 . toBaseEncodedString ( ) )
171
189
172
190
expect ( cid1 ) . to . have . property ( 'codec' , 'eth-block' )
191
+ expect ( cid1 ) . to . have . property ( 'code' , 144 )
173
192
expect ( cid1 ) . to . have . property ( 'version' , 1 )
174
193
expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
175
194
expect ( cid1 ) . to . have . property ( 'multibaseName' , 'base32' )
@@ -189,13 +208,15 @@ describe('CID', () => {
189
208
const cid0 = new CID ( 0 , 'dag-pb' , mh )
190
209
191
210
expect ( cid0 ) . to . have . property ( 'codec' , 'dag-pb' )
211
+ expect ( cid0 ) . to . have . property ( 'code' , 112 )
192
212
expect ( cid0 ) . to . have . property ( 'version' , 0 )
193
213
expect ( cid0 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
194
214
expect ( cid0 . toBaseEncodedString ( ) ) . to . eql ( '161g3c' )
195
215
196
216
const cid1 = new CID ( 1 , 'dag-cbor' , mh )
197
217
198
218
expect ( cid1 ) . to . have . property ( 'codec' , 'dag-cbor' )
219
+ expect ( cid1 ) . to . have . property ( 'code' , 113 )
199
220
expect ( cid1 ) . to . have . property ( 'version' , 1 )
200
221
expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
201
222
expect ( cid1 . toBaseEncodedString ( ) ) . to . eql ( 'bafyqaa3bmjrq' )
0 commit comments