From ddb43af01ab2f37c77544d3828f7d34eaf3275d9 Mon Sep 17 00:00:00 2001 From: Friedel Ziegelmayer Date: Wed, 9 Nov 2016 11:05:13 +0100 Subject: [PATCH] fix tests --- README.md | 3 ++- benchmarks/send.js | 2 +- src/index.js | 5 ++++- test/browser.js | 8 ++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cc741b8..d0c8b22 100644 --- a/README.md +++ b/README.md @@ -43,11 +43,12 @@ const secio = require('libp2p-secio') The current `secio` tag, usable in `multistream`. -### `encrypt(id, key, insecure)` +### `encrypt(id, key, insecure[, callback])` - `id: PeerId` - The id of the node. - `key: RSAPrivateKey` - The private key of the node. - `insecure: PullStream` - The insecure connection. +- `callback: Function` - Called if an error happens during the initialization. Returns the `insecure` connection provided, wrapped with secio. This is a pull-stream. diff --git a/benchmarks/send.js b/benchmarks/send.js index 097655c..84b0d16 100644 --- a/benchmarks/send.js +++ b/benchmarks/send.js @@ -46,7 +46,7 @@ suite.add('createKey', function (d) { pull( pull.infinite(), pull.take(100), - pull.map((val) => Buffer(val.toString())), + pull.map((val) => new Buffer(val.toString())), local ) diff --git a/src/index.js b/src/index.js index 4276fcf..afde604 100644 --- a/src/index.js +++ b/src/index.js @@ -23,7 +23,10 @@ module.exports = { if (!callback) { callback = (err) => { - throw err + if (err) { + console.error(err) + throw err + } } } diff --git a/test/browser.js b/test/browser.js index 1658edf..b412216 100644 --- a/test/browser.js +++ b/test/browser.js @@ -32,12 +32,8 @@ describe('secio browser <-> nodejs', () => { }) }) - it('encrypt', (done) => { - secio.encrypt(pid, pid._privKey, conn, (err, c) => { - expect(err).to.not.exist - encryptedConn = c - done() - }) + it('encrypt', () => { + secio.encrypt(pid, pid._privKey, conn) }) it('echo', (done) => {