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

fix: Adds tests for programmatic pubsub #1217

Closed
wants to merge 1 commit into from

Conversation

achingbrain
Copy link
Member

Attempts to address #1129.

There were no tests that invoked the subscribe method with only two arguments so I added some. I also added tests for other pubsub methods.

I found some existing pubsub tests but these go via the CLI and from what I can see the subscribe/publish test only uses one node.

Happy to make whatever changes are required, please let me know if anything needs changing to be more idiomatic for the project or if you'd like them added to the existing cli pubsub test suite instead.

@daviddias
Copy link
Member

We have a larger batch of tests coming from our interface-ipfs-core repo. They get loaded here -- https://github.com/ipfs/js-ipfs/blob/master/test/core/interface/pubsub.js -- and they are run against js-ipfs and js-ipfs-api to ensure that both have the same interface.

Could you diff your tests to that batch and add the ones that are different to that set? This way we are sure that both implementations comply.

Thanks @achingbrain :)

it('should subscribe without options', (done) => {
const handler = (event) => {
expect(event.data.toString('utf8')).to.equal(message)
done()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should unsubscribe before done to avoid side effects.

@achingbrain
Copy link
Member Author

Ah, nice. I think the invocation I wanted to test is covered here so this PR is sort of redundant.

@daviddias
Copy link
Member

@achingbrain do you confirm that #1129 is solved then?

@achingbrain
Copy link
Member Author

Yes, I think that issue should be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants