Skip to content

Commit

Permalink
fix: incoming stream conn (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos authored Nov 15, 2019
1 parent 39309a5 commit 1b2af2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 6 additions & 2 deletions test/pubsub.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 1b2af2c

Please sign in to comment.