mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-22 21:41:33 +00:00
fix: reject rather than throw in get peer info (#410)
The get peer info util consolidation from #400 exposed an issue with how bad values are being handled. Throwing the error can cause issues when promises are being used. Rejecting resolves this. I added a test case to validate the change.
This commit is contained in:
@ -123,5 +123,12 @@ describe('Get Peer Info', () => {
|
||||
|
||||
expect(error.code).to.eql('ERR_INVALID_PEER_TYPE')
|
||||
})
|
||||
|
||||
it('should callback with error for invalid non-peer multiaddr (promise)', () => {
|
||||
return getPeerInfoRemote(undefined)
|
||||
.then(expect.fail, (err) => {
|
||||
expect(err.code).to.eql('ERR_INVALID_PEER_TYPE')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user