Skip to content

feat: support passing profile init option #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ipfsd-daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ class Daemon {
args.push('--pass')
args.push('"' + initOptions.pass + '"')
}
if (initOptions.profile) {
// TODO: remove when JS IPFS supports profiles
if (this.opts.type === 'go') {
args.push('-p')
args.push(initOptions.profile)
} else {
log(`ignoring "profile" option, not supported for ${this.opts.type} node`)
}
}
run(this, args, { env: this.env }, (err, result) => {
if (err) {
return callback(err)
Expand Down
2 changes: 1 addition & 1 deletion test/add-retrieve.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('data can be put and fetched', () => {

const f = IPFSFactory.create(dfOpts)

f.spawn({ initOptions: { bits: dfOpts.bits } }, (err, _ipfsd) => {
f.spawn({ initOptions: { bits: dfOpts.bits, profile: 'test' } }, (err, _ipfsd) => {
expect(err).to.not.exist()
expect(_ipfsd).to.exist()
expect(_ipfsd.api).to.exist()
Expand Down
4 changes: 2 additions & 2 deletions test/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('ipfsd.api for Daemons', () => {
df.spawn({
start: false,
config: config,
initOptions: { bits: 1024 }
initOptions: { bits: 1024, profile: 'test' }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
ipfsd = _ipfsd
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('ipfsd.api for Daemons', () => {

df.spawn({
config: config,
initOptions: { bits: 1024 }
initOptions: { bits: 1024, profile: 'test' }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
const ipfsd = _ipfsd
Expand Down
2 changes: 1 addition & 1 deletion test/custom-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('custom API', function () {
IpfsClient: () => mockApi
})

f.spawn((err, ipfsd) => {
f.spawn({ initOptions: { profile: 'test' } }, (err, ipfsd) => {
if (err) return done(err)
expect(ipfsd.api).to.equal(mockApi)
// Restore a real API so that the node can be stopped properly
Expand Down
15 changes: 8 additions & 7 deletions test/spawn-options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Spawn options', function () {
init: false,
start: false,
disposable: false,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}

f.spawn(options, (err, _ipfsd) => {
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('Spawn options', function () {
it('create init and start node', function (done) {
this.timeout(20 * 1000)

f.spawn({ initOptions: { bits: fOpts.bits } },
f.spawn({ initOptions: { bits: fOpts.bits, profile: 'test' } },
(err, _ipfsd) => {
expect(err).to.not.exist()
expect(_ipfsd).to.exist()
Expand Down Expand Up @@ -213,7 +213,8 @@ describe('Spawn options', function () {
f.spawn({
defaultAddrs: true,
initOptions: {
bits: fOpts.bits
bits: fOpts.bits,
profile: 'test'
}
}, (err, ipfsd) => {
expect(err).to.not.exist()
Expand Down Expand Up @@ -246,7 +247,7 @@ describe('Spawn options', function () {
Bootstrap: ['/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic']
}

const options = { config: config, initOptions: { bits: fOpts.bits } }
const options = { config: config, initOptions: { bits: fOpts.bits, profile: 'test' } }

waterfall([
(cb) => f.spawn(options, cb),
Expand Down Expand Up @@ -317,7 +318,7 @@ describe('Spawn options', function () {
start: false,
repoPath: repoPath,
config: config,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}

series([
Expand Down Expand Up @@ -357,7 +358,7 @@ describe('Spawn options', function () {

const options = {
args: ['--enable-pubsub-experiment'],
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}

f.spawn(options, (err, _ipfsd) => {
Expand Down Expand Up @@ -396,7 +397,7 @@ describe('Spawn options', function () {

before(function (done) {
this.timeout(20 * 1000)
f.spawn({ initOptions: { bits: fOpts.bits } },
f.spawn({ initOptions: { bits: fOpts.bits, profile: 'test' } },
(err, _ipfsd) => {
expect(err).to.not.exist()
ipfsd = _ipfsd
Expand Down
20 changes: 10 additions & 10 deletions test/start-stop.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tests.forEach((fOpts) => {
init: true,
start: false,
disposable: true,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
expect(_ipfsd).to.exist()
Expand Down Expand Up @@ -135,7 +135,7 @@ tests.forEach((fOpts) => {

df.spawn({
start: false,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, ipfsd) => {
expect(err).to.not.exist()
ipfsd.start(['--should-not-exist'], (err) => {
Expand Down Expand Up @@ -165,7 +165,7 @@ tests.forEach((fOpts) => {
init: true,
start: false,
disposable: true,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, _ipfsd) => {
expect(err).to.not.exist()
expect(_ipfsd).to.exist()
Expand Down Expand Up @@ -247,7 +247,7 @@ tests.forEach((fOpts) => {

df.spawn({
start: false,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, ipfsd) => {
expect(err).to.not.exist()
ipfsd.start(['--should-not-exist'], (err) => {
Expand All @@ -270,7 +270,7 @@ tests.forEach((fOpts) => {

df.spawn({
exec,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, daemon) => {
expect(err).to.not.exist()
expect(daemon).to.exist()
Expand Down Expand Up @@ -302,7 +302,7 @@ tests.forEach((fOpts) => {
process.env = Object.assign({}, process.env, fOpts.type === 'go'
? { IPFS_GO_EXEC: exec } : { IPFS_JS_EXEC: exec })
df.spawn({
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, daemon) => {
expect(err).to.not.exist()
expect(daemon).to.exist()
Expand Down Expand Up @@ -335,7 +335,7 @@ tests.forEach((fOpts) => {

df.spawn({
exec,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, daemon) => {
expect(err).to.not.exist()
expect(daemon).to.exist()
Expand All @@ -356,7 +356,7 @@ tests.forEach((fOpts) => {

const df = IPFSFactory.create(dfConfig)
df.spawn({
initOptions: { bits: fOpts.bits },
initOptions: { bits: fOpts.bits, profile: 'test' },
repoPath: ipfsd.repoPath,
disposable: false
}, (err, daemon) => {
Expand All @@ -383,7 +383,7 @@ tests.forEach((fOpts) => {
init: false,
start: false,
exec: exec,
initOptions: { bits: fOpts.bits }
initOptions: { bits: fOpts.bits, profile: 'test' }
}, (err, daemon) => {
expect(err).to.not.exist()
expect(daemon).to.exist()
Expand Down Expand Up @@ -418,7 +418,7 @@ tests.forEach((fOpts) => {
start: false,
disposable: false,
repoPath: tempDir(fOpts.type),
initOptions: { bits: fOpts.bits },
initOptions: { bits: fOpts.bits, profile: 'test' },
config: {
Addresses: {
Swarm: [`/ip4/127.0.0.1/tcp/0`],
Expand Down