From ca99ce994ea533e60e875b40775403ceace0e7bb Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Mon, 8 Jul 2019 12:20:33 +0200 Subject: [PATCH] fix: use strict signing properly and fix callback issue --- src/index.js | 9 +++++++++ test/pubsub.spec.js | 5 ----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index ce3b4c7831..f5b13002fc 100644 --- a/src/index.js +++ b/src/index.js @@ -50,6 +50,12 @@ class PubsubBaseProtocol extends EventEmitter { this.peerId = this.libp2p.peerInfo.id } + /** + * If message signing should be required for incoming messages + * @type {boolean} + */ + this.strictSigning = options.strictSigning + /** * Map of topics to which peers are subscribed to * @@ -374,6 +380,9 @@ class PubsubBaseProtocol extends EventEmitter { if (err) return callback(err) callback(null, valid) }) + } else { + // The message is valid + nextTick(callback, null, true) } } } diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index 7f570376a1..dfff9c8c8b 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -103,11 +103,6 @@ describe('pubsub base protocol', () => { psA._buildMessage(message, (err, signedMessage) => { expect(err).to.not.exist() - // const bytesToSign = Buffer.concat([ - // SignPrefix, - // Message.encode(normalizeOutRpcMessage(message)) - // ]) - psA.validate(signedMessage, (err, verified) => { expect(verified).to.eql(true) done(err)