@@ -9,6 +9,7 @@ const path = require('path')
99const fs = require ( 'fs' )
1010const crypto = require ( 'crypto' )
1111const os = require ( 'os' )
12+ const multibase = require ( 'multibase' )
1213
1314describe ( 'object' , ( ) => runOnAndOff ( ( thing ) => {
1415 let ipfs
@@ -33,22 +34,15 @@ describe('object', () => runOnAndOff((thing) => {
3334 } )
3435 } )
3536
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' , ( ) => {
3739 return ipfs ( 'object new --cid-base=base64' ) . then ( ( out ) => {
3840 expect ( out ) . to . eql (
3941 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n'
4042 )
4143 } )
4244 } )
4345
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-
5246 it ( 'get' , ( ) => {
5347 return ipfs ( 'object get QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n' ) . then ( ( out ) => {
5448 const result = JSON . parse ( out )
@@ -86,13 +80,18 @@ describe('object', () => runOnAndOff((thing) => {
8680 } )
8781
8882 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+ } )
9188 . then ( cid => ipfs ( `object get ${ cid } --cid-base=base64` ) )
9289 . then ( out => {
9390 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+ } )
9695 } )
9796 } )
9897
@@ -104,7 +103,8 @@ describe('object', () => runOnAndOff((thing) => {
104103 } )
105104 } )
106105
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' , ( ) => {
108108 return ipfs ( 'object put test/fixtures/test-data/node.json --cid-base=base64' )
109109 . then ( ( out ) => {
110110 expect ( out ) . to . eql (
@@ -133,7 +133,7 @@ describe('object', () => runOnAndOff((thing) => {
133133 } )
134134 } )
135135
136- it ( 'unadulterated data' , function ( ) {
136+ it ( 'unaltered data' , function ( ) {
137137 this . timeout ( 10 * 1000 )
138138
139139 // has to be big enough to span several DAGNodes
@@ -163,11 +163,17 @@ describe('object', () => runOnAndOff((thing) => {
163163 } )
164164
165165 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+ } )
168171 . then ( cid => ipfs ( `object links ${ cid } --cid-base=base64` ) )
169172 . 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+ } )
171177 } )
172178 } )
173179
@@ -182,7 +188,8 @@ describe('object', () => runOnAndOff((thing) => {
182188 } )
183189 } )
184190
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' , ( ) => {
186193 return ipfs ( 'object patch append-data QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n test/fixtures/test-data/badconfig --cid-base=base64' ) . then ( ( out ) => {
187194 expect ( out ) . to . eql (
188195 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n'
@@ -198,7 +205,8 @@ describe('object', () => runOnAndOff((thing) => {
198205 } )
199206 } )
200207
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' , ( ) => {
202210 return ipfs ( 'object patch set-data QmfY37rjbPCZRnhvvJuQ46htW3VCAWziVB991P79h6WSv6 test/fixtures/test-data/badconfig --cid-base=base64' ) . then ( ( out ) => {
203211 expect ( out ) . to . eql (
204212 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n'
@@ -214,7 +222,8 @@ describe('object', () => runOnAndOff((thing) => {
214222 } )
215223 } )
216224
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' , ( ) => {
218227 return ipfs ( 'object patch add-link QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n foo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn --cid-base=base64' ) . then ( ( out ) => {
219228 expect ( out ) . to . eql (
220229 'mAXASIOEVPbXq2xYoEsRZhaPB61btcy1x359osjv4a2L/lgPs\n'
@@ -230,7 +239,8 @@ describe('object', () => runOnAndOff((thing) => {
230239 } )
231240 } )
232241
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' , ( ) => {
234244 return ipfs ( 'object patch rm-link QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK foo --cid-base=base64' ) . then ( ( out ) => {
235245 expect ( out ) . to . eql (
236246 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n'
0 commit comments