diff --git a/src/ipfsd-daemon.js b/src/ipfsd-daemon.js index 997d6045..cd2873cd 100644 --- a/src/ipfsd-daemon.js +++ b/src/ipfsd-daemon.js @@ -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) diff --git a/test/add-retrieve.spec.js b/test/add-retrieve.spec.js index c40057de..1b6d4db9 100644 --- a/test/add-retrieve.spec.js +++ b/test/add-retrieve.spec.js @@ -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() diff --git a/test/api.spec.js b/test/api.spec.js index ef96159e..593c388a 100644 --- a/test/api.spec.js +++ b/test/api.spec.js @@ -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 @@ -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 diff --git a/test/custom-api.spec.js b/test/custom-api.spec.js index ec19eee3..43694433 100644 --- a/test/custom-api.spec.js +++ b/test/custom-api.spec.js @@ -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 diff --git a/test/spawn-options.spec.js b/test/spawn-options.spec.js index 011d693c..0e94fa68 100644 --- a/test/spawn-options.spec.js +++ b/test/spawn-options.spec.js @@ -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) => { @@ -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() @@ -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() @@ -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), @@ -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([ @@ -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) => { @@ -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 diff --git a/test/start-stop.node.js b/test/start-stop.node.js index c06a4900..2a5e12e1 100644 --- a/test/start-stop.node.js +++ b/test/start-stop.node.js @@ -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() @@ -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) => { @@ -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() @@ -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) => { @@ -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() @@ -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() @@ -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() @@ -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) => { @@ -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() @@ -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`],