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

Commit 377e329

Browse files
committed
test: add interface-ipfs-core ping tests
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent 9d84e51 commit 377e329

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

src/core/components/ping-pull-stream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ function getPeer (libp2pNode, statusStream, peerId, cb) {
5555
try {
5656
peerId = PeerId.createFromB58String(peerId)
5757
} catch (err) {
58-
return cb(err)
58+
return cb(Object.assign(err, {
59+
message: `failed to parse peer address '${peerId}': input isn't valid multihash`
60+
}))
5961
}
6062

6163
return libp2pNode.peerRouting.findPeer(peerId, cb)

test/core/interface/interface.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('interface-ipfs-core tests', () => {
1616
require('./key')
1717
if (isNode) {
1818
require('./swarm')
19+
require('./ping')
1920
require('./pubsub')
2021
require('./dht')
2122
}

test/core/interface/ping.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
const test = require('interface-ipfs-core')
5+
const parallel = require('async/parallel')
6+
7+
const IPFS = require('../../../src')
8+
9+
const DaemonFactory = require('ipfsd-ctl')
10+
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })
11+
12+
const nodes = []
13+
const common = {
14+
setup: function (callback) {
15+
callback(null, {
16+
spawnNode: (cb) => {
17+
df.spawn({
18+
initOptions: { bits: 512 }
19+
}, (err, _ipfsd) => {
20+
if (err) {
21+
return cb(err)
22+
}
23+
24+
nodes.push(_ipfsd)
25+
cb(null, _ipfsd.api)
26+
})
27+
}
28+
})
29+
},
30+
teardown: function (callback) {
31+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
32+
}
33+
}
34+
35+
test.ping(common)

0 commit comments

Comments
 (0)