This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 295
+155
−48
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6a6ffed
fix(ping): convert the ping messages to lowercase
JGAntunes fdf3c4b
test: add interface-core-api ping tests and fix impl
alanshaw 47950a9
chore: update interface-ipfs-core dependency
alanshaw a3bc3dd
fix: update asserted error message
alanshaw da791f6
chore: update interface-ipfs-core dependency
alanshaw 7bc7d3e
chore: upgrade ipfsd-ctl and go-ipfs-dep dependencies
alanshaw 6b291e3
chore: upgrade interface-ipfs-core dependency
alanshaw ea3abf2
fix: more robust ping tests
alanshaw 71bf65e
fix: remove .only
alanshaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
'use strict' | ||
|
||
// Converts IPFS API ping messages to lowercase | ||
// | ||
// { | ||
// Success: true, | ||
// Text: 'foobar', | ||
// Time: 0 | ||
// } | ||
// | ||
|
||
module.exports = function pingMessageConverter (obj) { | ||
if (!isPingMessage(obj)) throw new Error('Invalid ping message received') | ||
return { | ||
success: obj.Success, | ||
time: obj.Time, | ||
text: obj.Text | ||
} | ||
} | ||
|
||
function isPingMessage (obj) { | ||
return obj && typeof obj.Success === 'boolean' | ||
} |
This file contains hidden or 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,27 @@ | ||
'use strict' | ||
|
||
const TransformStream = require('readable-stream').Transform | ||
const pingMessageConverter = require('./ping-message-converter') | ||
|
||
class PingMessageStream extends TransformStream { | ||
constructor (options) { | ||
const opts = Object.assign(options || {}, { objectMode: true }) | ||
super(opts) | ||
} | ||
|
||
_transform (obj, enc, callback) { | ||
try { | ||
const msg = pingMessageConverter(obj) | ||
this.push(msg) | ||
|
||
if (!msg.success) { | ||
throw new Error(msg.text) | ||
} | ||
} catch (err) { | ||
return callback(err) | ||
} | ||
callback() | ||
} | ||
} | ||
|
||
module.exports = PingMessageStream |
This file contains hidden or 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 hidden or 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,32 @@ | ||
/* eslint-env mocha */ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
'use strict' | ||
|
||
const test = require('interface-ipfs-core') | ||
const parallel = require('async/parallel') | ||
|
||
const IPFSApi = require('../../src') | ||
const f = require('../utils/factory') | ||
|
||
const nodes = [] | ||
const common = { | ||
setup: function (callback) { | ||
callback(null, { | ||
spawnNode: (cb) => { | ||
f.spawn({ initOptions: { bits: 1024 } }, (err, _ipfsd) => { | ||
if (err) { | ||
return cb(err) | ||
} | ||
|
||
nodes.push(_ipfsd) | ||
cb(null, IPFSApi(_ipfsd.apiAddr)) | ||
}) | ||
} | ||
}) | ||
}, | ||
teardown: function (callback) { | ||
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) | ||
} | ||
} | ||
|
||
test.ping(common) |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can now update this to 0.4.15 and also update ipfsd-ctl :)