Skip to content

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed Nov 4, 2020
1 parent 336ee0c commit 33fac9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/dialer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Dialer {
* @param {number} [options.concurrency = MAX_PARALLEL_DIALS] - Number of max concurrent dials.
* @param {number} [options.perPeerLimit = MAX_PER_PEER_DIALS] - Number of max concurrent dials per peer.
* @param {number} [options.timeout = DIAL_TIMEOUT] - How long a dial attempt is allowed to take.
* @param {object} [options.resolvers = {}]
* @param {object} [options.resolvers = {}] - multiaddr resolvers to use when dialing
*/
constructor ({
transportManager,
Expand Down
18 changes: 3 additions & 15 deletions test/dialing/resolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,10 @@ describe('Dialing (resolvable addresses)', () => {
sinon.spy(transport, 'dial')

// Resolver stub
let firstCall = false
let secondCall = false

const stub = sinon.stub(Resolver.prototype, 'resolveTxt')
stub.callsFake(() => {
if (!firstCall) {
firstCall = true
// Return an array of dnsaddr
return Promise.resolve(getDnsaddrStub(remoteId))
} else if (!secondCall) {
secondCall = true
// Address failed to resolve
return Promise.reject(new Error())
}
return Promise.resolve(getDnsRelayedAddrStub(remoteId))
})
stub.onCall(0).callsFake(() => Promise.resolve(getDnsaddrStub(remoteId)))
stub.onCall(1).callsFake(() => Promise.reject(new Error()))
stub.callsFake(() => Promise.resolve(getDnsRelayedAddrStub(remoteId)))

// Dial with address resolve
const connection = await libp2p.dial(dialAddr)
Expand Down

0 comments on commit 33fac9a

Please sign in to comment.