-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: callback with error for invalid or non-peer multiaddr (#232)
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
const expect = chai.expect | ||
|
||
const getPeerInfo = require('../src/get-peer-info') | ||
|
||
describe('getPeerInfo', () => { | ||
it('should callback with error for invalid string multiaddr', (done) => { | ||
getPeerInfo(null)('INVALID MULTIADDR', (err) => { | ||
expect(err).to.exist() | ||
expect(err.message).to.contain('must start with a "/"') | ||
done() | ||
}) | ||
}) | ||
|
||
it('should callback with error for invalid non-peer multiaddr', (done) => { | ||
getPeerInfo(null)('/ip4/8.8.8.8/tcp/1080', (err) => { | ||
expect(err).to.exist() | ||
expect(err.message).to.equal('peer multiaddr instance or string must include peerId') | ||
done() | ||
}) | ||
}) | ||
}) |