-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conversation
Thank you for submitting this PR!
Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution. |
I can update the test if the change looks good and makes sense. (was having some issue running the test locally) |
Thanks for opening this, it looks great. To get this over the line it needs:
|
@achingbrain Thanks, done! please let me know how it looks. |
The PR looks ok but the code doesn't seem to work - that is the protocols array is always empty whether the node is started or not. @jacobheun @vasco-santos is the peer store the right place to be fetching supported protocols from for the running node? |
it('should have protocols property', async () => { | ||
const res = await ipfs.id() | ||
|
||
expect(res).to.have.a.property('protocols').that.is.an('array') |
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.
This should assert that there are protocols present, at a minimum I think /ipfs/id/1.0.0
should be supported
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.
There should be a handful of protocols, I'd assert them all as they shouldn't change very frequently. There may be differences in Node.js vs browser, depending on modules included, but I think they are currently equivalent.
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.
Got ["/floodsub/1.0.0", "/ipfs/bitswap/1.0.0", "/ipfs/bitswap/1.1.0", "/ipfs/bitswap/1.2.0", "/ipfs/id/1.0.0", "/ipfs/id/push/1.0.0", "/ipfs/ping/1.0.0", "/libp2p/circuit/relay/0.1.0", "/meshsub/1.0.0", "/meshsub/1.1.0"]
, adding those to the assertions. Thanks guys!
Thanks for checking. AFAIK peerstore seems to be having it (I referenced https://github.com/ipfs/go-ipfs/blob/master/core/commands/id.go#L154) |
|
||
if (libp2p) { | ||
// only available while the node is running | ||
addresses = libp2p.transportManager.getAddrs() | ||
protocols = libp2p.peerStore.protoBook.get(peerId) || [] |
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.
Self protocols aren't currently stored in the peer store, so they need to be retrieved from the upgrader for now.
protocols = libp2p.peerStore.protoBook.get(peerId) || [] | |
protocols = Array.from(libp2p.upgrader.protocols.keys()) |
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.
Done! Thanks @jacobheun
it('should have protocols property', async () => { | ||
const res = await ipfs.id() | ||
|
||
expect(res).to.have.a.property('protocols').that.is.an('array') |
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.
There should be a handful of protocols, I'd assert them all as they shouldn't change very frequently. There may be differences in Node.js vs browser, depending on modules included, but I think they are currently equivalent.
dcb63c9
to
d282a16
Compare
Thanks again for submitting this, it'll go out in the next release.
I think you should be able to use the |
@achingbrain Thanks for merging this. Sounds interesting, I can take a look at id command for fetching metadata of other nodes. |
Adds `.protocols` property to the output of `ipfs.id` which contains all libp2p protocols supported by the current node. Closes ipfs/js-ipfs#3219
addresses issue #3219