@@ -14,6 +14,7 @@ const mh = require('multihashes')
14
14
const CID = require ( 'cids' )
15
15
const IPLDResolver = require ( 'ipld-resolver' )
16
16
const loadFixture = require ( 'aegir/fixtures' )
17
+ const each = require ( 'async/each' )
17
18
18
19
function stringifyMh ( files ) {
19
20
return files . map ( ( file ) => {
@@ -466,6 +467,52 @@ module.exports = (repo) => {
466
467
} )
467
468
)
468
469
} )
470
+
471
+ it ( 'will import files with CID version 1' , ( done ) => {
472
+ const createInputFile = ( path , size ) => {
473
+ const name = String ( Math . random ( ) + Date . now ( ) )
474
+ path = path [ path . length - 1 ] === '/' ? path : path + '/'
475
+ return {
476
+ path : path + name + '.txt' ,
477
+ content : Buffer . alloc ( 262144 + 5 ) . fill ( 1 )
478
+ }
479
+ }
480
+
481
+ const options = {
482
+ cidVersion : 1 ,
483
+ // Ensures we use DirSharded for the data below
484
+ shardSplitThreshold : 3
485
+ }
486
+
487
+ const onCollected = ( err , files ) => {
488
+ if ( err ) return done ( err )
489
+
490
+ const file = files [ 0 ]
491
+ expect ( file ) . to . exist ( )
492
+
493
+ each ( files , ( file , cb ) => {
494
+ const cid = new CID ( file . multihash ) . toV1 ( )
495
+ ipldResolver . get ( cid , cb )
496
+ } , done )
497
+ }
498
+
499
+ pull (
500
+ pull . values ( [
501
+ createInputFile ( '/foo' , 10 ) ,
502
+ createInputFile ( '/foo' , 60 ) ,
503
+ createInputFile ( '/foo/bar' , 78 ) ,
504
+ createInputFile ( '/foo/baz' , 200 ) ,
505
+ // Bigger than maxChunkSize
506
+ createInputFile ( '/foo' , 262144 + 45 ) ,
507
+ createInputFile ( '/foo/bar' , 262144 + 134 ) ,
508
+ createInputFile ( '/foo/bar' , 262144 + 79 ) ,
509
+ createInputFile ( '/foo/bar' , 262144 + 876 ) ,
510
+ createInputFile ( '/foo/bar' , 262144 + 21 )
511
+ ] ) ,
512
+ importer ( ipldResolver , options ) ,
513
+ pull . collect ( onCollected )
514
+ )
515
+ } )
469
516
} )
470
517
} )
471
518
}
0 commit comments