@@ -11,53 +11,62 @@ const pull = require('pull-stream')
1111const IPFS = require ( '../../src/core' )
1212const createTempRepo = require ( '../utils/create-repo-nodejs.js' )
1313
14- describe ( 'files dir' , ( ) => {
15- const files = [ ]
16- for ( let i = 0 ; i < 1005 ; i ++ ) {
17- files . push ( {
18- path : 'test-folder/' + i ,
19- content : Buffer . from ( 'some content ' + i )
20- } )
14+ describe ( 'files directory (sharding tests)' , ( ) => {
15+ function createTestFiles ( ) {
16+ const files = [ ]
17+
18+ for ( let i = 0 ; i < 1005 ; i ++ ) {
19+ files . push ( {
20+ path : 'test-folder/' + i ,
21+ content : Buffer . from ( 'some content ' + i )
22+ } )
23+ }
24+
25+ return files
2126 }
2227
2328 describe ( 'without sharding' , ( ) => {
2429 let ipfs
2530
2631 before ( function ( done ) {
27- this . timeout ( 15 * 1000 )
32+ this . timeout ( 30 * 1000 )
2833
2934 ipfs = new IPFS ( {
3035 repo : createTempRepo ( ) ,
3136 config : {
3237 Addresses : {
3338 Swarm : [ ]
3439 } ,
35- Bootstrap : [ ]
40+ Bootstrap : [ ] ,
41+ Discovery : {
42+ MDNS : {
43+ Enabled : false
44+ }
45+ }
3646 }
3747 } )
38- ipfs . once ( 'start ' , done )
48+ ipfs . once ( 'ready ' , done )
3949 } )
4050
41- after ( ( done ) => ipfs . stop ( done ) )
51+ after ( function ( done ) {
52+ this . timeout ( 30 * 1000 )
53+ ipfs . stop ( done )
54+ } )
4255
4356 it ( 'should be able to add dir without sharding' , function ( done ) {
4457 this . timeout ( 30 * 1000 )
4558
4659 pull (
47- pull . values ( files ) ,
60+ pull . values ( createTestFiles ( ) ) ,
4861 ipfs . files . createAddPullStream ( ) ,
4962 pull . collect ( ( err , results ) => {
5063 expect ( err ) . to . not . exist ( )
5164 const last = results [ results . length - 1 ]
52- expect ( last . path ) . to . be . eql ( 'test-folder' )
53- expect ( last . hash ) . to . be . eql ( 'QmWWM8ZV6GPhqJ46WtKcUaBPNHN5yQaFsKDSQ1RE73w94Q' )
65+ expect ( last . path ) . to . eql ( 'test-folder' )
66+ expect ( last . hash ) . to . eql ( 'QmWWM8ZV6GPhqJ46WtKcUaBPNHN5yQaFsKDSQ1RE73w94Q' )
5467 done ( )
5568 } )
5669 )
57-
58- after ( ( done ) => {
59- ipfs . stop ( ( ) => done ( ) ) // ignore stop errors
60- } )
6170 } )
6271 } )
6372
@@ -73,28 +82,36 @@ describe('files dir', () => {
7382 Addresses : {
7483 Swarm : [ ]
7584 } ,
76- Bootstrap : [ ]
85+ Bootstrap : [ ] ,
86+ Discovery : {
87+ MDNS : {
88+ Enabled : false
89+ }
90+ }
7791 } ,
7892 EXPERIMENTAL : {
7993 sharding : true
8094 }
8195 } )
82- ipfs . once ( 'start ' , done )
96+ ipfs . once ( 'ready ' , done )
8397 } )
8498
85- after ( ( done ) => ipfs . stop ( done ) )
99+ after ( function ( done ) {
100+ this . timeout ( 30 * 1000 )
101+ ipfs . stop ( done )
102+ } )
86103
87104 it ( 'should be able to add dir with sharding' , function ( done ) {
88105 this . timeout ( 30 * 1000 )
89106
90107 pull (
91- pull . values ( files ) ,
108+ pull . values ( createTestFiles ( ) ) ,
92109 ipfs . files . createAddPullStream ( ) ,
93110 pull . collect ( ( err , results ) => {
94111 expect ( err ) . to . not . exist ( )
95112 const last = results [ results . length - 1 ]
96- expect ( last . path ) . to . be . eql ( 'test-folder' )
97- expect ( last . hash ) . to . be . eql ( 'QmY8TxNWtNViN7syd2DHazPqu21qWfSNjzCDe78e4YMsUD ' )
113+ expect ( last . path ) . to . eql ( 'test-folder' )
114+ expect ( last . hash ) . to . eql ( 'Qmb3JNLq2KcvDTSGT23qNQkMrr4Y4fYMktHh6DtC7YatLa ' )
98115 done ( )
99116 } )
100117 )
0 commit comments