From 1b2af2c08c612db814cf953b3eb5894e68530ac5 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 15 Nov 2019 15:04:19 +0100 Subject: [PATCH] fix: incoming stream conn (#30) --- src/index.js | 6 +++--- test/pubsub.spec.js | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index 27b386ab74..f13c4cfa38 100644 --- a/src/index.js +++ b/src/index.js @@ -146,10 +146,10 @@ class PubsubBaseProtocol extends EventEmitter { * @param {Object} props * @param {string} props.protocol * @param {DuplexStream} props.strean - * @param {PeerId} props.remotePeer remote peer-id + * @param {Connection} props.connection connection */ - async _onIncomingStream ({ protocol, stream, remotePeer }) { - const peerInfo = await PeerInfo.create(remotePeer) + async _onIncomingStream ({ protocol, stream, connection }) { + const peerInfo = await PeerInfo.create(connection.remotePeer) peerInfo.protocols.add(protocol) const idB58Str = peerInfo.id.toB58String() diff --git a/test/pubsub.spec.js b/test/pubsub.spec.js index 3a868848b0..f827eb6265 100644 --- a/test/pubsub.spec.js +++ b/test/pubsub.spec.js @@ -180,7 +180,9 @@ describe('pubsub base protocol', () => { await handlerB({ protocol, stream: c1.stream, - remotePeer: peerInfoA.id + connection: { + remotePeer: peerInfoA.id + } }) expect(pubsubA.peers.size).to.be.eql(1) @@ -200,7 +202,9 @@ describe('pubsub base protocol', () => { await handlerB({ protocol, stream: c1.stream, - remotePeer: peerInfoA.id + connection: { + remotePeer: peerInfoA.id + } }) // Notice peers of disconnect