@@ -9,6 +9,7 @@ const path = require('path')
9
9
const fs = require ( 'fs' )
10
10
const crypto = require ( 'crypto' )
11
11
const os = require ( 'os' )
12
+ const multibase = require ( 'multibase' )
12
13
13
14
describe ( 'object' , ( ) => runOnAndOff ( ( thing ) => {
14
15
let ipfs
@@ -33,22 +34,15 @@ describe('object', () => runOnAndOff((thing) => {
33
34
} )
34
35
} )
35
36
36
- it ( 'should new and print CID encoded in specified base' , ( ) => {
37
+ // TODO: unskip after switch to v1 CIDs by default
38
+ it . skip ( 'should new and print CID encoded in specified base' , ( ) => {
37
39
return ipfs ( 'object new --cid-base=base64' ) . then ( ( out ) => {
38
40
expect ( out ) . to . eql (
39
41
'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n'
40
42
)
41
43
} )
42
44
} )
43
45
44
- it ( 'should new and print CID encoded in specified base' , ( ) => {
45
- return ipfs ( 'object new --cid-base=base32' ) . then ( ( out ) => {
46
- expect ( out ) . to . eql (
47
- 'bafybeihdwdcefgh4dqkjv67uzcmw7ojee6xedzdetojuzjevtenxquvyku\n'
48
- )
49
- } )
50
- } )
51
-
52
46
it ( 'get' , ( ) => {
53
47
return ipfs ( 'object get QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n' ) . then ( ( out ) => {
54
48
const result = JSON . parse ( out )
@@ -86,13 +80,18 @@ describe('object', () => runOnAndOff((thing) => {
86
80
} )
87
81
88
82
it ( 'should get and print CIDs encoded in specified base' , ( ) => {
89
- return ipfs ( 'object put test/fixtures/test-data/node.json' )
90
- . then ( out => out . replace ( 'added' , '' ) . trim ( ) )
83
+ return ipfs ( 'add test/fixtures/planets -r --cid-version=1' )
84
+ . then ( out => {
85
+ const lines = out . trim ( ) . split ( '\n' )
86
+ return lines [ lines . length - 1 ] . split ( ' ' ) [ 1 ]
87
+ } )
91
88
. then ( cid => ipfs ( `object get ${ cid } --cid-base=base64` ) )
92
89
. then ( out => {
93
90
const result = JSON . parse ( out )
94
- expect ( result . Hash ) . to . equal ( 'mAXASIKbM02Neyt6L1RRLYVEOuNlqDOzTvBboo3cI/u6f/+Vk' )
95
- expect ( result . Links [ 0 ] . Hash ) . to . equal ( 'mAXASIIq3psXnRzeHisc4Y8t2c50V1GZt5E5XVr9Vovnpq19E' )
91
+ expect ( multibase . isEncoded ( result . Hash ) ) . to . deep . equal ( 'base64' )
92
+ result . Links . forEach ( l => {
93
+ expect ( multibase . isEncoded ( l . Hash ) ) . to . deep . equal ( 'base64' )
94
+ } )
96
95
} )
97
96
} )
98
97
@@ -104,7 +103,8 @@ describe('object', () => runOnAndOff((thing) => {
104
103
} )
105
104
} )
106
105
107
- it ( 'should put and print CID encoded in specified base' , ( ) => {
106
+ // TODO: unskip after switch to v1 CIDs by default
107
+ it . skip ( 'should put and print CID encoded in specified base' , ( ) => {
108
108
return ipfs ( 'object put test/fixtures/test-data/node.json --cid-base=base64' )
109
109
. then ( ( out ) => {
110
110
expect ( out ) . to . eql (
@@ -133,7 +133,7 @@ describe('object', () => runOnAndOff((thing) => {
133
133
} )
134
134
} )
135
135
136
- it ( 'unadulterated data' , function ( ) {
136
+ it ( 'unaltered data' , function ( ) {
137
137
this . timeout ( 10 * 1000 )
138
138
139
139
// has to be big enough to span several DAGNodes
@@ -163,11 +163,17 @@ describe('object', () => runOnAndOff((thing) => {
163
163
} )
164
164
165
165
it ( 'should get links and print CIDs encoded in specified base' , ( ) => {
166
- return ipfs ( 'object put test/fixtures/test-data/node.json' )
167
- . then ( out => out . replace ( 'added' , '' ) . trim ( ) )
166
+ return ipfs ( 'add test/fixtures/planets -r --cid-version=1' )
167
+ . then ( out => {
168
+ const lines = out . trim ( ) . split ( '\n' )
169
+ return lines [ lines . length - 1 ] . split ( ' ' ) [ 1 ]
170
+ } )
168
171
. then ( cid => ipfs ( `object links ${ cid } --cid-base=base64` ) )
169
172
. then ( out => {
170
- expect ( out ) . to . equal ( 'mAXASIIq3psXnRzeHisc4Y8t2c50V1GZt5E5XVr9Vovnpq19E 8 some link\n' )
173
+ out . trim ( ) . split ( '\n' ) . forEach ( line => {
174
+ const cid = line . split ( ' ' ) [ 0 ]
175
+ expect ( multibase . isEncoded ( cid ) ) . to . deep . equal ( 'base64' )
176
+ } )
171
177
} )
172
178
} )
173
179
@@ -182,7 +188,8 @@ describe('object', () => runOnAndOff((thing) => {
182
188
} )
183
189
} )
184
190
185
- it ( 'should append-data and print CID encoded in specified base' , ( ) => {
191
+ // TODO: unskip after switch to v1 CIDs by default
192
+ it . skip ( 'should append-data and print CID encoded in specified base' , ( ) => {
186
193
return ipfs ( 'object patch append-data QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n test/fixtures/test-data/badconfig --cid-base=base64' ) . then ( ( out ) => {
187
194
expect ( out ) . to . eql (
188
195
'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n'
@@ -198,7 +205,8 @@ describe('object', () => runOnAndOff((thing) => {
198
205
} )
199
206
} )
200
207
201
- it ( 'should set-data and print CID encoded in specified base' , ( ) => {
208
+ // TODO: unskip after switch to v1 CIDs by default
209
+ it . skip ( 'should set-data and print CID encoded in specified base' , ( ) => {
202
210
return ipfs ( 'object patch set-data QmfY37rjbPCZRnhvvJuQ46htW3VCAWziVB991P79h6WSv6 test/fixtures/test-data/badconfig --cid-base=base64' ) . then ( ( out ) => {
203
211
expect ( out ) . to . eql (
204
212
'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n'
@@ -214,7 +222,8 @@ describe('object', () => runOnAndOff((thing) => {
214
222
} )
215
223
} )
216
224
217
- it ( 'should add-link and print CID encoded in specified base' , ( ) => {
225
+ // TODO: unskip after switch to v1 CIDs by default
226
+ it . skip ( 'should add-link and print CID encoded in specified base' , ( ) => {
218
227
return ipfs ( 'object patch add-link QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n foo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn --cid-base=base64' ) . then ( ( out ) => {
219
228
expect ( out ) . to . eql (
220
229
'mAXASIOEVPbXq2xYoEsRZhaPB61btcy1x359osjv4a2L/lgPs\n'
@@ -230,7 +239,8 @@ describe('object', () => runOnAndOff((thing) => {
230
239
} )
231
240
} )
232
241
233
- it ( 'should rm-link and print CID encoded in specified base' , ( ) => {
242
+ // TODO: unskip after switch to v1 CIDs by default
243
+ it . skip ( 'should rm-link and print CID encoded in specified base' , ( ) => {
234
244
return ipfs ( 'object patch rm-link QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK foo --cid-base=base64' ) . then ( ( out ) => {
235
245
expect ( out ) . to . eql (
236
246
'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n'
0 commit comments