From a58b5bc57720940199159c102f21d2134d41a1f7 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 7 Mar 2018 11:22:08 +0000 Subject: [PATCH] fixes doc and adds test assertion that peer is a PeerId in return value from swarm.peers --- SPEC/SWARM.md | 2 +- js/src/swarm.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/SPEC/SWARM.md b/SPEC/SWARM.md index ec9aa5593..edf041b40 100644 --- a/SPEC/SWARM.md +++ b/SPEC/SWARM.md @@ -88,7 +88,7 @@ If `opts.verbose` is set to `true` additional information, such as `latency` is `callback` must follow `function (err, peerInfos) {}` signature, where `err` is an error if the operation was not successful. `peerInfos` will be an array of the form - `addr: Multiaddr` -- `peer: [PeerInfo]()` +- `peer: PeerId` - `latency: String` Only if `verbose: true` was passed Starting with `go-ipfs 0.4.5` these additional properties are provided diff --git a/js/src/swarm.js b/js/src/swarm.js index 9c43869a4..45284b448 100644 --- a/js/src/swarm.js +++ b/js/src/swarm.js @@ -9,6 +9,7 @@ const expect = chai.expect chai.use(dirtyChai) const series = require('async/series') const multiaddr = require('multiaddr') +const PeerId = require('peer-id') const os = require('os') const path = require('path') const hat = require('hat') @@ -79,6 +80,7 @@ module.exports = (common) => { expect(peer).to.have.a.property('addr') expect(multiaddr.isMultiaddr(peer.addr)).to.equal(true) expect(peer).to.have.a.property('peer') + expect(PeerId.isPeerId(peer.peer)).to.equal(true) expect(peer).to.not.have.a.property('latency') // only available in 0.4.5