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

fix: remove node globals #2932

Merged
merged 25 commits into from
May 7, 2020
Merged

fix: remove node globals #2932

merged 25 commits into from
May 7, 2020

Conversation

hugomrdias
Copy link
Member

@hugomrdias hugomrdias commented Mar 20, 2020

This PR main goal is to remove node globals and is the final PR of this awesome endeavour #2924

I tried to split the commits to make it easier to digest https://github.com/ipfs/js-ipfs/pull/2932/commits

Running aegir test -t browser --node false still fails in a couple of tests because im still waiting on merges in readable-stream and simple-peer but its ready for review.

todo:

  • write an example for using other ipld formats

@hugomrdias
Copy link
Member Author

looks like libp2p-crypto is working

})

it('should add from a HTTP URL with redirection', async () => {
const text = `TEST${Math.random()}`
const url = echoUrl(text) + '?foo=bar#buzz'
Copy link
Member

Choose a reason for hiding this comment

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

Why did the extra stuff at the end of the url get removed?

Copy link
Member Author

@hugomrdias hugomrdias Apr 30, 2020

Choose a reason for hiding this comment

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

its not needed and the new echoserver uses searchParams

@@ -483,7 +486,7 @@ module.exports = (common, options) => {
expect(expectedResult.err).to.not.exist()
expect(result[0].cid.toString()).to.equal(expectedResult[0].cid.toString())
expect(result[0].size).to.equal(expectedResult[0].size)
expect(result[0].path).to.equal(text)
// expect(result[0].path).to.equal(text)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be uncommented?

Copy link
Member Author

Choose a reason for hiding this comment

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

same reason as below, path is download now and not the text, i will remove the comment

const addOpts = { wrapWithDirectory: true }

const [result, expectedResult] = await Promise.all([
all(ipfs.add(urlSource(url), addOpts)),
all(ipfs.add([{ path: filename, content: Buffer.from(filename) }], addOpts))
all(ipfs.add([{ path: 'download', content: Buffer.from(filename) }], addOpts))
Copy link
Member

Choose a reason for hiding this comment

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

Why has filename changed to 'download'?

Copy link
Member Author

Choose a reason for hiding this comment

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

this has to do with the echoserver download endpoint, the previous server was simpler and one could do just any path and it would respond, but the new has defined endpoints for different stuff.
So urlSource uses the pathname of the url for the path (http://localhost:3000/download?data=helloworld) we get "download" in file path, i could do a catch-all endpoint just for this use-case so we can build the file path with the url pathname but i didn’t see the value because the test still is testing whats needed so i left it like that.

const { expect } = require('interface-ipfs-core/src/utils/mocha')
const all = require('it-all')
const MockPreloadNode = require('../utils/mock-preload-node')
const MockPreloadNode = require('../utils/mock-preload-node-utils')
Copy link
Member

Choose a reason for hiding this comment

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

Should this not be const MockPreloadNode = require('../utils/mock-preload-node') ?

Copy link
Member Author

Choose a reason for hiding this comment

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

i split the server from the helpers so we don't include the server stuff in the tests bundle

Copy link
Member

@achingbrain achingbrain left a comment

Choose a reason for hiding this comment

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

LGTM, just a few small nits

@achingbrain achingbrain merged commit d0d2f74 into master May 7, 2020
@achingbrain achingbrain deleted the test/node-globals branch May 7, 2020 08:09
oliveriosousa pushed a commit to oliveriosousa/js-ipfs that referenced this pull request Jul 26, 2021
SgtPooki referenced this pull request in ipfs/js-kubo-rpc-client Aug 18, 2022
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