-
Notifications
You must be signed in to change notification settings - Fork 124
feature: add pubsub (tests and API Spec) #101
Conversation
|
||
const expect = require('chai').expect | ||
const isNode = require('detect-node') | ||
const PubsubMessage = require('../../src/pubsub-message') // eslint-disable-line no-unused-vars |
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.
Why include this if we don't need it?
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.
We need it eventually. Leaving it there as a placeholder.
However, these should not be required from '../src' but from ipfs-api. @dignifiedquire how can I do that? interface-ipfs-api tests that refer to components in js-ipfs-api (and the same components will prolly be used in js-ipfs) but are not publicly exposed by the module?
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 shouldn't require them, they should be passed in through the setup
function
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.
How? How passed what? Can you provide an example?
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.
The tests have a before
filter, which calls common.setup
, so you can pass more things through there. You could either add the functionality to the factory
or as a third parameter.
e00d8e7
to
638dc65
Compare
describe('immutable properties', () => { | ||
const message = PubsubMessageUtils.create('A', 'hello', '123', ['hello world']) | ||
|
||
it('from', () => { |
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.
If this doesn't throw any exception, won't the test pass?
Should be something like this instead:
let err = null
try {
message.from = 'not allowed'
} catch (e) {
err = e
}
expect(e).to.be.an('error')
expect(e.toString()).to.equal(`TypeError: Cannot set property from of #<PubsubMessage> which has only a getter`)
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're right. Will fix this.
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.
Fixed.
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.
Not sure if that's the right fix. You just added a expect in the try part, which would not get run if there is an error and now we're doing different assertions depending on if the code throws an exception or not. The tests should not be able to change the executed code path.
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.
Thanks, all this got me thinking.
I changed it a bit and just pushed a new commit to make it even more implicit that we're testing immutability here: check that the values are the same as before if no error is thrown.
loop() | ||
}) | ||
|
||
it('call subscribe 1k times', (done) => { |
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 is implicitly tested in the subscribe/unsubscribe 1k times, so we can remove this test.
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.
Unsubscribe changes the internal state. This test is meant to make sure that NOT calling unsubscribe before calling subscribe again doesn't change the state and works as expected.
}) | ||
}) | ||
|
||
it('call publish 1k times', (done) => { |
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 is implicitly tested in the subscribe/unsubscribe 1k times, so we can remove this test.
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.
Same as above.
0a221fc
to
c9b9751
Compare
5eadaff
to
501c304
Compare
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.
@haadcode I believe I don't understand correctly the purpose of pubsub.peers, could you clarify/fix the docs please?
expect(err.toString()).to.equal(`Error: Not subscribed to '${topic}'`) | ||
done() | ||
}) | ||
}) |
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.
@haadcode why would it fail if I'm not subscribed to a topic? Could you clarify?
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.
My logic here was that the state of the subscriptions is the source of truth: if you're subscribed, you can query it, cancel it, etc. If you're not, you can't.
What would you expect to receive if you're not subscribed to the topic and call .peers()? En empty list?
Say we have a use case like in the tests for the "waitForPeers", we callback only after we received peers. We don't subscribe to the topic but we keep polling pubsub.peers in the hopes that it returns the peer some day. We keep waiting and waiting and it doesn't seem to work, we check connectivity, we start looking elsewhere, because peers just returns an empty array. That's pretty confusing behaviour for the API. In this case, I believe it's better to tell the user with an error that "hey, what' you're maybe trying to do, will not work".
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.
What would you expect to receive if you're not subscribed to the topic and call .peers()? En empty list?
For me peers(topic)
tells me I should expect "give me the peers I have in my peerSet that are subscribed to a given topic".
I'm ok merging this when you are. |
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.
@haadcode found problems running the new enabled tests in js-ipfs-api.
Also, the process.stdout.write
won't fly in the browser, right now I'm commenting them out, but it is preferable to find an alternative logging.
@@ -143,7 +154,7 @@ module.exports = (common) => { | |||
}) | |||
}) | |||
|
|||
it.skip('returns no peers within 10 seconds', (done) => { | |||
it('returns no peers within 10 seconds', (done) => { |
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.
@haadcode this test is failing in js-ipfs-api
@@ -159,7 +170,7 @@ module.exports = (common) => { | |||
}) | |||
}) | |||
|
|||
it.skip('doesn\'t return extra peers', (done) => { | |||
it('doesn\'t return extra peers', (done) => { |
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.
@haadcode this one too
@@ -182,10 +193,16 @@ module.exports = (common) => { | |||
}) | |||
}) | |||
|
|||
it.skip('returns peers for a topic - one peer', (done) => { | |||
it('returns peers for a topic - one peer', (done) => { |
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.
@haadcode and this one
@@ -182,10 +193,16 @@ module.exports = (common) => { | |||
}) | |||
}) | |||
|
|||
it.skip('returns peers for a topic - one peer', (done) => { | |||
it('returns peers for a topic - one peer', (done) => { | |||
// Currently go-ipfs returns peers that have not been subscribed to the topic | |||
// Enable when go-ipfs has been fixed |
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.
Why not filter at js-ipfs-api?
Found some issues when running the new tests you added/enabled in js-ipfs-api. They run well in js-ipfs though. |
@diasdavid this is due to using a (old) version go-ipfs that has bugs for those tests. As far as I know they're now fixed in master but we need to wait for go-ipfs 0.4.5-rc1 release to verify the tests are working. ~~Shall we put this to "blocked" until we have that?~~~ We don't need to put this on hold, but note that when running these tests with js-ipfs-api, one needs to use go-ipfs 0.4.5 binary built from git (master). |
outputProgress() | ||
ipfs2.pubsub.publish(topic, expectedString, (err) => { | ||
expect(err).to.not.exist | ||
process.nextTick(() => loop()) |
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.
@haadcode this is till Node.js specific
- `options` - type: Object, optional, might contain the following properties: | ||
- `discover`: type: Boolean - Will use the DHT to find | ||
|
||
`callback` must follow `function (err, subscription) {}` where Subscription is a Node.js Stream in Object mode, emiting a `data` event for each new message on the subscribed topic.`err` is an error if the operation was not successful. |
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.
I don't think this is a good interface. We all know the issues of node.js streams and using object streams is even more problematic, as some modules (like hapi.js) don't even work with object streams.
I would propose a simpler api using raw EventEmitter
.
const handler = onMessage
ipfs.pubsub.subscribe('mytopic', {discover: true}, onMessage)
ipfs.pubsub.unsubscribe('mytopic', onMessage)
Which would be implemented using EventEmitter
and mostly aliases for .on
and removeListener
. Where removeListener
does a check onto emitter.listenerCount(topic) and if that is 0
it will actually unsubscribe from the underlying thing.
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 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.
I can implement this, but would like some feedback from @haadcode and @gavinmcdermott before :)
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 will require changes in the js-ipfs-api PR too
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.
Absolutely. Let's do it!
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.
Awesome! Please reuse open connections in js-ipfs-api, i.e: If a subscription request is already open, avoid opening a new one, just increase the ref count.
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.
@dignifiedquire - Awesome. Let me know if there's any areas you need help / support in this!
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. | ||
|
||
If no `callback` is passed, a [promise][] is returned. | ||
|
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.
Missing docs on the value that is resolved
|
||
- `topic` - type: String | ||
|
||
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. |
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.
Missing docs on the value that is resolved
|
||
### Features | ||
|
||
* **object:** add template option to object.new ([2f23617](https://github.com/ipfs/interface-ipfs-core/commit/2f23617)) |
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.
why is there a changelog in a pr?
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.
It seems that is from a rebase
@@ -41,6 +41,19 @@ module.exports = (common) => { | |||
done() | |||
}) | |||
}) | |||
|
|||
it.skip('template unixfs-dir', (done) => { |
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 seems entirely unrelated
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.
same as #101 (comment)
const topics = ['one', 'two', 'three'] | ||
series( | ||
topics.map((t) => (cb) => ipfs1.pubsub.subscribe(t, cb)) | ||
, (err, subs) => { |
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.
please put the comma at the end of the line
@@ -156,7 +157,8 @@ module.exports = (common) => { | |||
}) | |||
}) | |||
|
|||
it('returns no peers within 10 seconds', (done) => { | |||
// I don't understand the purpose of this test | |||
it.skip('returns no peers within 10 seconds', (done) => { |
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.
@haadcode ^^
dab167d
to
3adf1ae
Compare
}) | ||
|
||
describe('.peers', () => { | ||
it('returns an error when not subscribed to a topic', (done) => { |
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 was an open question in this interface. I personally don't understand why the question "Tell me who I know that is subscribed to a topic" needs to fail in case I'm not interested to the topic.
@haadcode could you clarify your argument for it to be this way?
@gavinmcdermott @dignifiedquire thoughts?
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.
I would prefer not throwing
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.
As a consumer, I'd be a little surprised to encounter a failure case when asking for a list of the peers subscribed to a topic. Here's the rational behind this for me:
- When I'm making this call, I feel like I'm in the mode of asking the following: "Will you please give me a list of all the people I know who are subscribed to this topic?"
- To me, the above question feels disconnected from any notion of my subscriptions
I'm not set on this by any means; this is just my mental model.
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.
I'm absolutely fine not throwing an error.
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 is a way to look at it as "closed" channels. Kinda like, if you don't participate, you're not allowed to know. But I think this can be achieved with topic CIDs at a later point.
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.
Alright, will change to not throwing behaviour
|
||
it.skip("doesn't return extra peers", (done) => { | ||
// Currently go-ipfs returns peers that have not been | ||
// subscribed to the topic. Enable when go-ipfs has been fixed |
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.
What this means is that js-ipfs-api
should filter out those who aren't subscribed
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.
I don't see how js-ipfs-api could do that if go doesn't return tge right values. The api only knows about local subs
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.
I see, fair point :( Is there a feature request for the go-ipfs implementation? @whyrusleeping @Kubuxu ?
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.
I think it was resolved recently, can you give it another try?
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.
It's fixed in master, but not the build we can pull in
], (err) => { | ||
expect(err).to.not.exist | ||
setTimeout(() => { | ||
ipfs1.pubsub.peers(topic, (err, peers) => { |
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.
Are these peers
, peerInfo objects?
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.
they are peer ids encoded as b58 multihash
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.
so strings
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.
It would be awesome to have a way to fetch peer info from the http api, namely known multiaddrs, public key, supported transports, etc //cc @whyrusleeping
function sub1 (msg) { | ||
inbox1.push(msg.data.toString()) | ||
// TODO: enable when go-ipfs is unbroken | ||
// expect(msg.from).to.be.eql(ipfs2.peerId.id) |
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.
Is there a issue that can also be linked here?
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.
yes, it's mentioned in the first case, I just didn't want to duplicated it all over the file
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.
👍
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. | ||
|
||
If no `callback` is passed, a [promise][] is returned. | ||
|
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.
Please complete
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
|
||
- `topic` - type: String | ||
|
||
`callback` must follow `function (err) {}` signature, where `err` is an error if the operation was not successful. |
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.
Please complete
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
Ready for next review |
|
||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.pubsub.publish(topic, data, callback) | ||
|
||
- `topic` - type: String | ||
- `data` - type: Buffer |
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.
Did you intentionally remove the data
argument?
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.
no :/
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.
fixed
##### `JavaScript` - ipfs.pubsub.publish(topic, data, callback) | ||
|
||
- `topic: string` | ||
- `callback: (Error) => ()` - Calls back with an error or nothing if the publish was successfull. |
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.
It is missing the description of data
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 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.
fixed
describe('.publish', () => { | ||
it('message from string', (done) => { | ||
ipfs1.pubsub.publish(topic, 'hello friend', done) | ||
}) |
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.
I'm worried with accepting plain strings as argument. The issue that we had last week Monday was because the initial pubsub code @haadcode wrote would always convert any value to a Buffer on the publish implementation, but then, because the tests were written like expect(dataReceived).to.equal('some string')
, the implementation had a data.toString()
internally as a quick patch, and when I changed that to make it an operation in the outside (like we have here now, see below, preserving the buffer type), it made orbit stop working because there was an assumption that 'data' was a string, since orbit publishes strings (or was publishing).
Strings and Buffers are one of banes of JavaScript, it would be better to force it to be just Buffer and no other type (creating a test here to make sure it fails with anything non buffer), to avoid future problems.
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.
We could also check strictly for string or Buffer, but nothing else, which makes it a bit nicer on the user, but avoids issues like passing an array by accident.
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.
Note that the case I present was exactly because of a user expecting if it published a 'string', it would come out a 'string'.
But yeah, at least, restrict everything else.
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.
which makes it a bit nicer on the user
The other option would be to have a big bold note "Any string will be converted to a Buffer"
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.
- needs to be resolved before the merge
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.
I agree @diasdavid that this is something we should decide now as it has bitten us already in a bad way. What do we do in other function that accept similar data as a param, like object.put? It might be a good idea to follow similar convention. If it's string+buffer, then what David proposes makes sense (always convert to buffer and make it as explicit to the user as possible (docs + erroring on anything but string or buffer). If it's only a buffer, it would also make sense to me (input buffer, receive buffer). This is how I tried to approach it in js-ipfs-api: everything we receive is a string, so inputs should be strings (from user's perspective). Obviously we would need to change js-ipfs-api to convert all strings to buffers, and probably in a lot of use cases the user then converts the buffer back to a string, but I suppose it's a cost we could live with (and on a positive side, js-ipfs would be tiny bit faster because it only needs to use buffers).
So... I think I like the idea of accepting buffers-only the most, but it wouldn't be too bad if we accepted strings too.
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.
alright, going to change things to buffer only then
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
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.
Minor things, the String vs Buffer
needs a resolution, otherwise LGTM 👍
|
||
- `topic: string` | ||
- `options: Object` - (Optional), might contain the following properties: | ||
- `discover`: type: Boolean - Will use the DHT to find |
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.
"to find.." - sentence needs to be finished
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.
I think this is a great sentence :P
##### `JavaScript` - ipfs.pubsub.publish(topic, data, callback) | ||
|
||
- `topic: string` | ||
- `callback: (Error) => ()` - Calls back with an error or nothing if the publish was successfull. |
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.
🛎
- `topic: string` | ||
- `callback: (Error) => ()` - Calls back with an error or nothing if the publish was successfull. | ||
|
||
- Returns: `Promise` if no `callback` was passed otherwise `undefined`. |
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.
We have used always: If no
callback is passed, a [promise][] is returned.
, I'm fine changing the sentence, but I do like consistency :)
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.
changed back
@@ -42,7 +42,7 @@ module.exports = (common) => { | |||
}) | |||
}) | |||
|
|||
it('template unixfs-dir', (done) => { | |||
it.skip('template unixfs-dir', (done) => { |
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.
Why do we need to skip this one?
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.
I don't even know why this is here in the first place
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.
fixed
done() | ||
} | ||
} | ||
} |
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.
Can't we use the chai
checkmark thing?
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.
I honestly found this to be simpler to use and understand. But not opposed to switching.
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.
Sounds good :)
describe('.publish', () => { | ||
it('message from string', (done) => { | ||
ipfs1.pubsub.publish(topic, 'hello friend', done) | ||
}) |
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.
- needs to be resolved before the merge
const handler2 = (msg) => { | ||
expect(msg.data.toString()).to.be.eql('hello') | ||
check() | ||
} |
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.
We've been kind of declaring functions always with the word function
, it has some benefits as making it easy to grep. We kind of have followed (naturally) the pattern of always using function
throughout the code and I would like to keep it consistent, unless there is a strong case not to.
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 have used function
I try to use const name = ()
especially inside other functions and to avoid using functions before they are declared, as it is very unfortunate that function
declarations are hoisted to the top level, allowing for code to use functions before they have been declared.
return done(err) | ||
} | ||
// give some time to let everything connect | ||
setTimeout(done, 300) |
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.
Does this need to be here? Will it fail it it doesn't?
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.
yes
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.
sometimes
20392b8
to
1a82890
Compare
🎉 100 comments |
This PR will add tests for the upcoming pubsub API.
Note that this PR is dependent on ipfs-inactive/js-ipfs-http-client#465.