Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
test: add interface-ipfs-core ping tests
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw committed May 16, 2018
1 parent 9d84e51 commit 377e329
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/components/ping-pull-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ function getPeer (libp2pNode, statusStream, peerId, cb) {
try {
peerId = PeerId.createFromB58String(peerId)
} catch (err) {
return cb(err)
return cb(Object.assign(err, {
message: `failed to parse peer address '${peerId}': input isn't valid multihash`
}))
}

return libp2pNode.peerRouting.findPeer(peerId, cb)
Expand Down
1 change: 1 addition & 0 deletions test/core/interface/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('interface-ipfs-core tests', () => {
require('./key')
if (isNode) {
require('./swarm')
require('./ping')
require('./pubsub')
require('./dht')
}
Expand Down
35 changes: 35 additions & 0 deletions test/core/interface/ping.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-env mocha */
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, {
spawnNode: (cb) => {
df.spawn({
initOptions: { bits: 512 }
}, (err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

test.ping(common)

0 comments on commit 377e329

Please sign in to comment.