Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
fix: dont compare empty strings (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun authored Apr 11, 2019
1 parent 866e5a6 commit bb1a235
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function ourAddresses (peerInfo) {
: `${addr}/ipfs/${ourPeerId}`
return ourAddrs.concat([addr, otherAddr])
}, [])
.filter(a => Boolean(a))
.concat(`/ipfs/${ourPeerId}`)
}

Expand Down
17 changes: 17 additions & 0 deletions test/transport-manager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ describe('Transport Manager', () => {
expect(dialableAddrs[0].toString()).to.equal('/ip6/::1/tcp/4001')
})

it('should filter out our addrs that start with /ipfs/', () => {
const queryAddrs = [
'/ip4/127.0.0.1/tcp/4002/ipfs/QmebzNV1kSzLfaYpSZdShuiABNUxoKT1vJmCdxM2iWsM2j'
].map(a => Multiaddr(a))

const ourAddrs = [
'/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
]

ourAddrs.forEach(a => peerInfo.multiaddrs.add(a))

const dialableAddrs = TransportManager.dialables(dialAllTransport, queryAddrs, peerInfo)

expect(dialableAddrs).to.have.length(1)
expect(dialableAddrs[0]).to.eql(queryAddrs[0])
})

it('should filter our addresses over relay/rendezvous', () => {
const peerId = peerInfo.id.toB58String()
const queryAddrs = [
Expand Down

0 comments on commit bb1a235

Please sign in to comment.