@@ -32,6 +32,7 @@ describe('CID', () => {
32
32
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
33
33
expect ( cid ) . to . have . property ( 'version' , 0 )
34
34
expect ( cid ) . to . have . property ( 'multihash' ) . that . eql ( multihash . fromB58String ( mhStr ) )
35
+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
35
36
36
37
expect ( cid . toBaseEncodedString ( ) ) . to . be . eql ( mhStr )
37
38
} )
@@ -46,6 +47,7 @@ describe('CID', () => {
46
47
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
47
48
expect ( cid ) . to . have . property ( 'version' , 0 )
48
49
expect ( cid ) . to . have . property ( 'multihash' ) . that . eql ( mh )
50
+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
49
51
50
52
expect ( cid . toBaseEncodedString ( ) ) . to . eql ( mhStr )
51
53
done ( )
@@ -58,6 +60,7 @@ describe('CID', () => {
58
60
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
59
61
expect ( cid ) . to . have . property ( 'version' , 0 )
60
62
expect ( cid ) . to . have . property ( 'multihash' )
63
+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
61
64
} )
62
65
63
66
it ( 'throws on invalid BS58Str multihash ' , ( ) => {
@@ -108,19 +111,21 @@ describe('CID', () => {
108
111
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
109
112
expect ( cid ) . to . have . property ( 'version' , 1 )
110
113
expect ( cid ) . to . have . property ( 'multihash' )
114
+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base58btc' )
111
115
112
116
expect ( cid . toBaseEncodedString ( ) ) . to . be . eql ( cidStr )
113
117
} )
114
118
115
119
it ( 'handles CID (no multibase)' , ( ) => {
116
- const cidStr = 'zdj7Wd8AMwqnhJGQCbFxBVodGSBG84TM7Hs1rcJuQMwTyfEDS '
120
+ const cidStr = 'bafybeidskjjd4zmr7oh6ku6wp72vvbxyibcli2r6if3ocdcy7jjjusvl2u '
117
121
const cidBuf = Buffer . from ( '017012207252523e6591fb8fe553d67ff55a86f84044b46a3e4176e10c58fa529a4aabd5' , 'hex' )
118
122
119
123
const cid = new CID ( cidBuf )
120
124
121
125
expect ( cid ) . to . have . property ( 'codec' , 'dag-pb' )
122
126
expect ( cid ) . to . have . property ( 'version' , 1 )
123
127
expect ( cid ) . to . have . property ( 'multihash' )
128
+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base32' )
124
129
125
130
expect ( cid . toBaseEncodedString ( ) ) . to . be . eql ( cidStr )
126
131
} )
@@ -131,6 +136,7 @@ describe('CID', () => {
131
136
expect ( cid ) . to . have . property ( 'codec' , 'dag-cbor' )
132
137
expect ( cid ) . to . have . property ( 'version' , 1 )
133
138
expect ( cid ) . to . have . property ( 'multihash' )
139
+ expect ( cid ) . to . have . property ( 'multibaseName' , 'base32' )
134
140
} )
135
141
136
142
it ( 'can roundtrip through cid.toBaseEncodedString()' , ( ) => {
@@ -140,6 +146,7 @@ describe('CID', () => {
140
146
expect ( cid1 ) . to . have . property ( 'codec' ) . that . eql ( cid2 . codec )
141
147
expect ( cid1 ) . to . have . property ( 'version' ) . that . eql ( cid2 . version )
142
148
expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( cid2 . multihash )
149
+ expect ( cid1 ) . to . have . property ( 'multibaseName' ) . that . eql ( cid2 . multibaseName )
143
150
} )
144
151
145
152
it ( 'handles multibyte varint encoded codec codes' , ( ) => {
@@ -151,9 +158,11 @@ describe('CID', () => {
151
158
expect ( cid1 ) . to . have . property ( 'codec' , 'eth-block' )
152
159
expect ( cid1 ) . to . have . property ( 'version' , 1 )
153
160
expect ( cid1 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
161
+ expect ( cid1 ) . to . have . property ( 'multibaseName' , 'base32' )
154
162
expect ( cid2 ) . to . have . property ( 'codec' , 'eth-block' )
155
163
expect ( cid2 ) . to . have . property ( 'version' , 1 )
156
164
expect ( cid2 ) . to . have . property ( 'multihash' ) . that . eql ( mh )
165
+ expect ( cid2 ) . to . have . property ( 'multibaseName' , 'base32' )
157
166
} )
158
167
159
168
it ( '.prefix' , ( ) => {
@@ -199,9 +208,9 @@ describe('CID', () => {
199
208
200
209
it ( 'returns a string in the base provided' , ( ) => {
201
210
const b58v1Str = 'zdj7Wd8AMwqnhJGQCbFxBVodGSBG84TM7Hs1rcJuQMwTyfEDS'
202
- const b32v1Str = 'bafybeidskjjd4zmr7oh6ku6wp72vvbxyibcli2r6if3ocdcy7jjjusvl2u '
211
+ const b64urlv1Str = 'uAXASIHJSUj5lkfuP5VPWf_VahvhARLRqPkF24QxY-lKaSqvV '
203
212
const cid = new CID ( b58v1Str )
204
- expect ( cid . toString ( 'base32 ' ) ) . to . equal ( b32v1Str )
213
+ expect ( cid . toString ( 'base64url ' ) ) . to . equal ( b64urlv1Str )
205
214
} )
206
215
} )
207
216
0 commit comments