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.
Lets us do things like `jsipfs config --bool EXPERIMENTAL.pubsub true` and have IPFS respect the flags in daemon and non-daemon mode License: MIT Signed-off-by: Alex Potsides <alex.potsides@protocol.ai>
- Loading branch information
1 parent
d394a12
commit c1dc38d
Showing
4 changed files
with
135 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
const dirtyChai = require('dirty-chai') | ||
const expect = chai.expect | ||
chai.use(dirtyChai) | ||
const IPFS = require('../../src/core') | ||
const parallel = require('async/parallel') | ||
|
||
// This gets replaced by `create-repo-browser.js` in the browser | ||
const createTempRepo = require('../utils/create-repo-nodejs.js') | ||
|
||
describe('options', () => { | ||
let repos = [] | ||
let repo | ||
|
||
beforeEach(() => { | ||
repo = createTempRepo() | ||
repos.push(repo) | ||
}) | ||
|
||
afterEach((done) => { | ||
parallel( | ||
repos.map(repo => (cb) => repo.teardown(cb)), | ||
done | ||
) | ||
}) | ||
|
||
it('should merge options with repo config', (done) => { | ||
let ipfs = new IPFS({ | ||
repo: repo, | ||
init: true, | ||
start: false | ||
}) | ||
|
||
expect(ipfs._options.EXPERIMENTAL).to.deep.equal({}) | ||
|
||
ipfs.once('ready', () => { | ||
// no experimental options have been set | ||
expect(ipfs._options.EXPERIMENTAL).to.deep.equal({}) | ||
|
||
// set an experimental option | ||
repo.config.set('EXPERIMENTAL.pubsub', true, (error) => { | ||
if (error) { | ||
return done(error) | ||
} | ||
|
||
ipfs = new IPFS({ | ||
repo: repo, | ||
init: true, | ||
start: false, | ||
EXPERIMENTAL: { | ||
sharding: true | ||
} | ||
}) | ||
|
||
// should only have the experimental option we passed to the constructor | ||
expect(ipfs._options.EXPERIMENTAL).to.deep.equal({sharding: true}) | ||
|
||
ipfs.once('ready', () => { | ||
// should have read experimental options from repo config and merged with constructor args | ||
expect(ipfs._options.EXPERIMENTAL).to.deep.equal({ | ||
sharding: true, | ||
pubsub: true | ||
}) | ||
|
||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |