This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const pull = require('pull-stream') | ||
|
||
const IPFS = require('../../src/core') | ||
const createTempRepo = require('../utils/create-repo-node.js') | ||
|
||
describe('files dir', () => { | ||
|
||
const files = [] | ||
for(let i = 0; i < 1005; i++) { | ||
files.push({ | ||
path: 'test-folder/' + i, | ||
content: new Buffer('some content ' + i) | ||
}) | ||
} | ||
|
||
describe('without sharding', () => { | ||
let ipfs | ||
|
||
before((done) => { | ||
ipfs = new IPFS({ | ||
repo: createTempRepo(), | ||
config: { | ||
Bootstrap: [] | ||
} | ||
}) | ||
ipfs.once('start', done) | ||
}) | ||
|
||
after((done) => { | ||
ipfs.stop(done) | ||
}) | ||
|
||
it('should be able to add dir without sharding', (done) => { | ||
pull( | ||
pull.values(files), | ||
ipfs.files.createAddPullStream(), | ||
pull.collect((err, results) => { | ||
const last = results[results.length - 1] | ||
expect(last.path).to.be.eql('test-folder') | ||
expect(last.hash).to.be.eql('QmWWM8ZV6GPhqJ46WtKcUaBPNHN5yQaFsKDSQ1RE73w94Q') | ||
done() | ||
}) | ||
) | ||
|
||
after((done) => { | ||
ipfs.stop(() => done()) // ignore stop errors | ||
}) | ||
|
||
}).timeout(4000) | ||
}) | ||
|
||
describe('with sharding', () => { | ||
let ipfs | ||
|
||
before((done) => { | ||
ipfs = new IPFS({ | ||
repo: createTempRepo(), | ||
config: { | ||
Bootstrap: [] | ||
}, | ||
EXPERIMENTAL: { | ||
sharding: true | ||
} | ||
}) | ||
ipfs.once('start', done) | ||
}) | ||
|
||
after((done) => { | ||
ipfs.stop(() => done()) // ignore stop errors | ||
}) | ||
|
||
it('should be able to add dir with sharding', (done) => { | ||
pull( | ||
pull.values(files), | ||
ipfs.files.createAddPullStream(), | ||
pull.collect((err, results) => { | ||
const last = results[results.length - 1] | ||
expect(last.path).to.be.eql('test-folder') | ||
expect(last.hash).to.be.eql('QmZjYC1kWrLmiRYbEmGSo2PEpMixzT2k2xoCKSBzt8KDcy') | ||
done() | ||
}) | ||
) | ||
|
||
}).timeout(4000) | ||
}) | ||
}) |