diff --git a/src/core/ipns/publisher.js b/src/core/ipns/publisher.js index d33713ae75..0c77031c56 100644 --- a/src/core/ipns/publisher.js +++ b/src/core/ipns/publisher.js @@ -67,7 +67,7 @@ class IpnsPublisher { let keys try { - keys = ipns.getIdKeys(peerId.id) + keys = ipns.getIdKeys(peerId.toBytes()) } catch (err) { log.error(err) return callback(err) diff --git a/test/cli/name-pubsub.js b/test/cli/name-pubsub.js index dbd89b8698..29a9adb685 100644 --- a/test/cli/name-pubsub.js +++ b/test/cli/name-pubsub.js @@ -83,24 +83,21 @@ describe('name-pubsub', () => { // Connect before(function () { - return ipfsA('swarm', 'connect', bMultiaddr).then((out) => { - expect(out).to.eql(`connect ${bMultiaddr} success\n`) - }) + return ipfsA('swarm', 'connect', bMultiaddr) + .then((out) => { + expect(out).to.eql(`connect ${bMultiaddr} success\n`) + }) }) after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done)) describe('pubsub commands', () => { - before(function (done) { - this.timeout(50 * 1000) - done() - }) - it('should get enabled state of pubsub', function () { - return ipfsA('name pubsub state').then((res) => { - expect(res).to.exist() - expect(res).to.have.string('enabled') // enabled - }) + return ipfsA('name pubsub state') + .then((res) => { + expect(res).to.exist() + expect(res).to.have.string('enabled') // enabled + }) }) it('should subscribe on name resolve', function () { @@ -110,19 +107,17 @@ describe('name-pubsub', () => { .catch((err) => { expect(err).to.exist() // Not available (subscribed) - return Promise.all([ - ipfsB('pubsub ls'), - ipfsB('name pubsub subs') - ]) - .then((res) => { - expect(res).to.exist() - - expect(res[0]).to.exist() - expect(res[0]).to.have.string('/ipns/') // have an ipns subscribtion + return ipfsB('pubsub ls') + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.have.string('/ipns/') // have an ipns subscribtion - expect(res[1]).to.exist() - expect(res[1]).to.have.string(`/ipns/${nodeAId.id}`) // have subscription - }) + return ipfsB('name pubsub subs') + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.have.string(`/ipns/${nodeAId.id}`) // have subscription }) }) @@ -135,29 +130,27 @@ describe('name-pubsub', () => { expect(res).to.have.string('no subscription') // tried to cancel a not yet subscribed id return ipfsA(`name resolve ${nodeBId.id}`) - .catch((err) => { - expect(err).to.exist() // Not available (subscribed now) - - return ipfsA(`name pubsub cancel /ipns/${nodeBId.id}`) - .then((res) => { - expect(res).to.exist() - expect(res).to.have.string('canceled') // canceled now - - return Promise.all([ - ipfsA('pubsub ls'), - ipfsA('name pubsub subs') - ]) - .then((res) => { - expect(res).to.exist() - - expect(res[0]).to.exist() - expect(res[0]).to.not.have.string('/ipns/') // ipns subscribtion not available - - expect(res[1]).to.exist() - expect(res[1]).to.not.have.string(`/ipns/${nodeBId.id}`) // ipns subscribtion not available - }) - }) - }) + }) + .catch((err) => { + expect(err).to.exist() // Not available (subscribed now) + + return ipfsA(`name pubsub cancel /ipns/${nodeBId.id}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.have.string('canceled') // canceled now + + return ipfsA('pubsub ls') + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.not.have.string('/ipns/') // ipns subscribtion not available + + return ipfsA('name pubsub subs') + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.not.have.string(`/ipns/${nodeBId.id}`) // ipns subscribtion not available }) }) }) @@ -167,10 +160,11 @@ describe('name-pubsub', () => { before(function (done) { this.timeout(50 * 1000) - ipfsA('add src/init-files/init-docs/readme').then((out) => { - cidAdded = out.split(' ')[1] - done() - }) + ipfsA('add src/init-files/init-docs/readme') + .then((out) => { + cidAdded = out.split(' ')[1] + done() + }) }) it('should publish the received record to the subscriber', function () { @@ -182,30 +176,28 @@ describe('name-pubsub', () => { expect(res).to.satisfy(checkAll([emptyDirCid])) // Empty dir received (subscribed) return ipfsA(`name resolve ${nodeBId.id}`) - .catch((err) => { - expect(err).to.exist() // Not available (subscribed now) - - return ipfsB(`name publish ${cidAdded}`) - .then((res) => { - // published to IpfsB and published through pubsub to ipfsa - expect(res).to.exist() - expect(res).to.satisfy(checkAll([cidAdded, nodeBId.id])) - - return Promise.all([ - ipfsB(`name resolve ${nodeBId.id}`), - ipfsA(`name resolve ${nodeBId.id}`) - ]) - .then((res) => { - expect(res).to.exist() - - expect(res[0]).to.exist() - expect(res[0]).to.satisfy(checkAll([cidAdded])) - - expect(res[1]).to.exist() - expect(res[1]).to.satisfy(checkAll([cidAdded])) // value propagated to node B - }) - }) - }) + }) + .catch((err) => { + expect(err).to.exist() // Not available (subscribed now) + + return ipfsB(`name publish ${cidAdded}`) + }) + .then((res) => { + // published to IpfsB and published through pubsub to ipfsa + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded, nodeBId.id])) + + return ipfsB(`name resolve ${nodeBId.id}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded])) + + return ipfsA(`name resolve ${nodeBId.id}`) + }) + .then((res) => { + expect(res).to.exist() + expect(res).to.satisfy(checkAll([cidAdded])) // value propagated to node B }) }) }) @@ -235,30 +227,28 @@ describe('name-pubsub', () => { after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done)) - it('should get disabled state of pubsub', function (done) { - ipfsA('name pubsub state').then((res) => { - expect(res).to.exist() - expect(res).to.have.string('disabled') - - done() - }) + it('should get disabled state of pubsub', function () { + return ipfsA('name pubsub state') + .then((res) => { + expect(res).to.exist() + expect(res).to.have.string('disabled') + }) }) - it('should get error getting the available subscriptions', function (done) { - ipfsA('name pubsub subs').catch((err) => { - expect(err).to.exist() // error as it is disabled - expect(err.toString()).to.have.string('IPNS pubsub subsystem is not enabled') - done() - }) + it('should get error getting the available subscriptions', function () { + return ipfsA('name pubsub subs') + .catch((err) => { + expect(err).to.exist() // error as it is disabled + expect(err.toString()).to.have.string('IPNS pubsub subsystem is not enabled') + }) }) - it('should get error canceling a subscription', function (done) { - ipfsA('name pubsub cancel /ipns/QmSWxaPcGgf4TDnFEBDWz2JnbHywF14phmY9hNcAeBEK5v').catch((err) => { - expect(err).to.exist() // error as it is disabled - expect(err.toString()).to.have.string('IPNS pubsub subsystem is not enabled') - - done() - }) + it('should get error canceling a subscription', function () { + return ipfsA('name pubsub cancel /ipns/QmSWxaPcGgf4TDnFEBDWz2JnbHywF14phmY9hNcAeBEK5v') + .catch((err) => { + expect(err).to.exist() // error as it is disabled + expect(err.toString()).to.have.string('IPNS pubsub subsystem is not enabled') + }) }) }) })