Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

chore: convert tests async await #547

Closed

Conversation

PedroMiguelSS
Copy link
Contributor

@PedroMiguelSS PedroMiguelSS commented Oct 29, 2019

This PR converts tests to use async/await syntax.

package.json Outdated
"pump": "^3.0.0",
"readable-stream": "^3.1.1",
"streaming-iterables": "^4.1.0",
"through2": "^3.0.0"
},
"devDependencies": {
"aegir": "^20.0.0"
"aegir": "^20.3.2",
"ipfsd-ctl": "ipfs/js-ipfsd-ctl#feat/interface-tests"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will need to be merged & released before this PR can go in.

src/files-mfs/ls-pull-stream.js Outdated Show resolved Hide resolved
src/files-mfs/ls-readable-stream.js Outdated Show resolved Hide resolved
src/files-regular/cat-readable-stream.js Outdated Show resolved Hide resolved
src/miscellaneous/resolve.js Outdated Show resolved Hide resolved
src/swarm/disconnect.js Outdated Show resolved Hide resolved
src/swarm/connect.js Outdated Show resolved Hide resolved
src/repo/gc.js Outdated Show resolved Hide resolved
const cid = await ipfs.object.patch.addLink(testNodeCid, node1b.Links[0])
expect(node1bCid).to.eql(cid)

/* TODO: revisit this assertions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm having a hard time trying to figure several things out:

/* TODO: revisit this assertions.
      // note: make sure we can link js plain objects
      const content = Buffer.from(JSON.stringify({
        title: 'serialized object'
      }, null, 0))
      const result = await ipfs.add(content)
      expect(result).to.exist()
      expect(result).to.have.lengthOf(1)
      const object = result.pop()
      const node3 = {
        name: object.hash,
        multihash: object.hash,
        size: object.size
      }
      const node = await ipfs.object.patch.addLink(testNodeWithLinkMultihash, node3)
      expect(node).to.exist()
      testNodeWithLinkMultihash = node.multihash
      testLinkPlainObject = node3
      */

This seems to be a mix between code and pseudo-code. I don't know if I did correctly understand the goal of this test but I did try to do this: const node = await ipfs.object.patch.addLink(node1bCid, node3) where node1bCid is the cid of the node with link (as testNodeWithLinkMultihash indicates). However, I'm getting this error: Error: invalid path "": path does not begin with '/'.

Furthermore, this seems to be a different test (like a second test, testing plain objects this time) and thus, I think it should have its own test, separately of should add a link to an existing node test.

So, we can leave it as it currently is (commented), delete this test, or if you really want to keep it can you please help me? @achingbrain

@@ -120,33 +44,26 @@ module.exports = (createCommon, options) => {

expect(withoutChildCid).to.not.deep.equal(parentCid)
expect(withoutChildCid).to.deep.equal(nodeCid)

/* TODO: revisit this assertions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here: #547 (comment)

@PedroMiguelSS PedroMiguelSS changed the base branch from master to feat/interface-tests November 6, 2019 10:33
Copy link
Contributor

@hugomrdias hugomrdias left a comment

Choose a reason for hiding this comment

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

Really nice job!! Left some minor request.

src/dag/put.js Outdated Show resolved Hide resolved
src/files-mfs/read-pull-stream.js Show resolved Hide resolved
src/files-mfs/read-pull-stream.js Show resolved Hide resolved
src/files-regular/add-pull-stream.js Show resolved Hide resolved
src/files-regular/add-pull-stream.js Show resolved Hide resolved
src/files-regular/get-readable-stream.js Outdated Show resolved Hide resolved
src/files-regular/get-readable-stream.js Outdated Show resolved Hide resolved
src/files-regular/ls-pull-stream.js Show resolved Hide resolved
src/files-regular/refs-local-pull-stream.js Show resolved Hide resolved
src/files-regular/refs-pull-stream.js Show resolved Hide resolved
Copy link
Contributor

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Please address the other feedback that @achingbrain and @hugomrdias have and lets get this merged.

I'm ok with adding pull-to-promise for now. Pull streams will disappear completely soon. Lets not spend any more time refactoring this again.

package.json Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@alanshaw
Copy link
Contributor

@PedroMiguelSS I really would like to get this merged soon! There's been no activity for 10 days now - is there something you're blocked on?

@PedroMiguelSS
Copy link
Contributor Author

PedroMiguelSS commented Nov 11, 2019

No, I'm not blocked. There's been no activity for 6 days 😜 I was trying to finish adding --human flag to repo stat so I can open a new PR but I've been facing some problems. However you're right, it's about time to get this one merged. Let's do it. I'll focus on this one today.

@alanshaw
Copy link
Contributor

There's been no activity for 6 days 😜

You're right - my apologies

@PedroMiguelSS
Copy link
Contributor Author

Do not merge this yet. I'm still testing it.

@PedroMiguelSS
Copy link
Contributor Author

I did not forget about this, I'm just waiting for @hugomrdias to solve a dependencies related problem on his branch ipfs/js-ipfsd-ctl#feat/interface-tests, which my PR is depending on.

@PedroMiguelSS PedroMiguelSS force-pushed the chore/convert-tests-async-await branch from b05a77b to cdf6864 Compare November 13, 2019 01:47
@PedroMiguelSS
Copy link
Contributor Author

PedroMiguelSS commented Nov 13, 2019

My changes are all done.

@hugomrdias, I did run these tests on ipfs/js-ipfs-http-client#fix/update-promise-setup and somehow the http-client src code was not being used. ipfs/js-ipfsd-ctl#feat/interface-tests is installing http-client as a dependency and the node_modules/ipfs-http-client/src folder is being used instead. Something is wrong with ipfsd-ctl because we shouldn't have http-client being installed on http-client 🤷‍♂

Btw, this PR will be merged from chore/convert-tests-async-await to @hugomrdias' feat/interface-tests branch. Should we change the target branch to master? @alanshaw

@PedroMiguelSS PedroMiguelSS force-pushed the chore/convert-tests-async-await branch from cdf6864 to 8bd5541 Compare November 13, 2019 17:28
@alanshaw
Copy link
Contributor

I have no idea when feat/interface-tests is going to be completed - does this PR need to target it? Can we add a shim that makes the existing interface look like the new one temporarily and then remove it when feat/interface-tests is merged and released? This is a HUGE PR and it needs to get merged ASAP.

@PedroMiguelSS
Copy link
Contributor Author

This PR must be closed in favor of #562.

@alanshaw alanshaw closed this Nov 21, 2019
@alanshaw alanshaw deleted the chore/convert-tests-async-await branch November 25, 2019 23:18
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.

4 participants