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

fix: pin.ls ignored opts when hash was present #375

Merged
merged 2 commits into from
Jul 16, 2019
Merged

Conversation

lidel
Copy link
Contributor

@lidel lidel commented Oct 21, 2018

This PR adds more detailed tests for pin.ls, including one that guards against issue described in ipfs-inactive/js-ipfs-http-client#875

@alanshaw
Copy link
Contributor

alanshaw commented Oct 30, 2018

This works against js-ipfs-api but when running against js-ipfs I get the following failures:

  interface-ipfs-core tests
    .pin.ls
Swarm listening on /ip4/127.0.0.1/tcp/50794/ipfs/QmR9L54Qb4WbmP3HSdKVtn7P842XeFfZZK21TCkNztWC7K
      ✓ should list all recursive pins
      ✓ should list all indirect pins
      1) should list all types of pins
      2) should list all types of pins (promised)
      ✓ should list all direct pins
      ✓ should list pins for a specific hash
      ✓ should list pins for a specific hash (promised)
      3) should throw an error on missing direct pins for a specific path
      4) should throw an error on missing link for a specific path
      ✓ should list indirect pins for a specific path
      ✓ should list recursive pins for a specific hash (promised)
    .pin.rm
Swarm listening on /ip4/127.0.0.1/tcp/50872/ipfs/QmQ6pDYHTJsjdrYnQQJgsVFJ1BwEGvmcH9MHdtneKKJq4B
      ✓ should remove a recursive pin
      ✓ should remove a direct pin (promised)
    .pin.add
Swarm listening on /ip4/127.0.0.1/tcp/50880/ipfs/QmUuQfnRESmKx9CRc9J9KgDXtgMAJZWtVWtoeJofUJtTHH
      ✓ should add a pin
      ✓ should add a pin (promised)


  11 passing (1s)
  4 failing

  1) interface-ipfs-core tests
       .pin.ls
         should list all types of pins:

      Uncaught AssertionError: expected [ Array(17) ] to have a length of 15 but got 17
      + expected - actual

      -17
      +15
      
      at ipfs.pin.ls (/Users/alan/Code/protocol-labs/interface-ipfs-core/js/src/pin/ls.js:109:32)
      at getIndirectKeys (src/core/components/pin.js:323:20)
      at eachLimit (src/core/components/pin.js:69:7)
      at node_modules/async/internal/once.js:12:16
      at iterateeCallback (node_modules/async/internal/eachOfLimit.js:48:24)
      at node_modules/async/internal/onlyOnce.js:12:16
      at dag._getRecursive (src/core/components/pin.js:65:9)
      at mapAsync (src/core/components/dag.js:163:11)
      at node_modules/async/internal/map.js:32:9
      at node_modules/async/internal/once.js:12:16
      at iteratorCallback (node_modules/async/eachOf.js:60:13)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/map.js:29:13
      at mapAsync (src/core/components/dag.js:163:11)
      at node_modules/async/internal/map.js:32:9
      at node_modules/async/internal/once.js:12:16
      at iteratorCallback (node_modules/async/eachOf.js:60:13)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/map.js:29:13
      at mapAsync (src/core/components/dag.js:163:11)
      at node_modules/async/internal/map.js:32:9
      at node_modules/async/internal/once.js:12:16
      at eachOfArrayLike (node_modules/async/eachOf.js:53:9)
      at exports.default (node_modules/async/eachOf.js:9:5)
      at _asyncMap (node_modules/async/internal/map.js:25:5)
      at node_modules/async/internal/doParallel.js:20:16
      at self.dag.get (src/core/components/dag.js:158:9)
      at _get (node_modules/ipld/src/index.js:131:9)
      at node_modules/async/internal/once.js:12:16
      at next (node_modules/async/waterfall.js:21:29)
      at node_modules/async/internal/onlyOnce.js:12:16
      at r.util.deserialize (node_modules/ipld/src/index.js:368:13)
      at multihashing (node_modules/ipld-dag-pb/src/dag-node/create.js:53:7)
      at Multihashing.Multihashing.digest (node_modules/multihashing-async/src/index.js:33:5)
      at setImmediate (node_modules/multihashing-async/src/utils.js:8:7)
      at Immediate.<anonymous> (node_modules/async/internal/setImmediate.js:27:16)

  2) interface-ipfs-core tests
       .pin.ls
         should list all types of pins (promised):

      AssertionError: expected [ Array(17) ] to have a length of 15 but got 17
      + expected - actual

      -17
      +15
      
      at ipfs.pin.ls.then (/Users/alan/Code/protocol-labs/interface-ipfs-core/js/src/pin/ls.js:139:34)

  3) interface-ipfs-core tests
       .pin.ls
         should throw an error on missing direct pins for a specific path:
     Uncaught AssertionError: expected [ Array(1) ] to not exist
      at ipfs.pin.ls (/Users/alan/Code/protocol-labs/interface-ipfs-core/js/src/pin/ls.js:200:31)
      at node_modules/async/internal/map.js:32:9
      at node_modules/async/internal/once.js:12:16
      at replenish (node_modules/async/internal/eachOfLimit.js:61:25)
      at iterateeCallback (node_modules/async/internal/eachOfLimit.js:50:17)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/map.js:29:13
      at pin._isPinnedWithType (src/core/components/pin.js:282:26)
      at someLimit (src/core/components/pin.js:366:16)
      at node_modules/async/internal/createTester.js:39:17
      at node_modules/async/internal/once.js:12:16
      at iterateeCallback (node_modules/async/internal/eachOfLimit.js:48:24)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/createTester.js:30:21
      at pinset.hasDescendant (src/core/components/pin.js:361:13)
      at node_modules/async/internal/createTester.js:39:17
      at node_modules/async/internal/once.js:12:16
      at iteratorCallback (node_modules/async/eachOf.js:60:13)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/createTester.js:30:21
      at node_modules/async/internal/createTester.js:39:17
      at node_modules/async/internal/once.js:12:16
      at iteratorCallback (node_modules/async/eachOf.js:60:13)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/createTester.js:30:21
      at some (src/core/components/pin-set.js:73:48)
      at node_modules/async/internal/createTester.js:24:13
      at eachOfArrayLike (node_modules/async/eachOf.js:65:9)
      at exports.default (node_modules/async/eachOf.js:9:5)
      at node_modules/async/internal/createTester.js:23:9
      at node_modules/async/internal/doParallel.js:20:16
      at searchChildren (src/core/components/pin-set.js:71:9)
      at dag.get (src/core/components/pin-set.js:80:13)
      at _get (node_modules/ipld/src/index.js:131:9)
      at node_modules/async/internal/once.js:12:16
      at next (node_modules/async/waterfall.js:21:29)
      at node_modules/async/internal/onlyOnce.js:12:16
      at r.util.deserialize (node_modules/ipld/src/index.js:368:13)
      at multihashing (node_modules/ipld-dag-pb/src/dag-node/create.js:53:7)
      at Multihashing.Multihashing.digest (node_modules/multihashing-async/src/index.js:33:5)
      at setImmediate (node_modules/multihashing-async/src/utils.js:8:7)
      at Immediate.<anonymous> (node_modules/async/internal/setImmediate.js:27:16)

  4) interface-ipfs-core tests
       .pin.ls
         should throw an error on missing link for a specific path:
     Uncaught AssertionError: expected [Error: no link named "I-DONT-EXIST.txt" under QmVJV2VF9Qf7rJUFdimhpZDhkyyumM1i4CjjGcss5rqJPa] not to be empty
      at ipfs.pin.ls (/Users/alan/Code/protocol-labs/interface-ipfs-core/js/src/pin/ls.js:210:31)
      at resolvePath (src/core/components/pin.js:263:29)
      at node_modules/async/internal/map.js:32:9
      at node_modules/async/internal/once.js:12:16
      at iteratorCallback (node_modules/async/eachOf.js:58:13)
      at node_modules/async/internal/onlyOnce.js:12:16
      at node_modules/async/internal/map.js:29:13
      at follow (src/core/utils.js:127:16)
      at self._ipld.get (src/core/components/object.js:255:9)
      at _get (node_modules/ipld/src/index.js:131:9)
      at node_modules/async/internal/once.js:12:16
      at next (node_modules/async/waterfall.js:21:29)
      at node_modules/async/internal/onlyOnce.js:12:16
      at r.util.deserialize (node_modules/ipld/src/index.js:368:13)
      at multihashing (node_modules/ipld-dag-pb/src/dag-node/create.js:53:7)
      at Multihashing.Multihashing.digest (node_modules/multihashing-async/src/index.js:33:5)
      at setImmediate (node_modules/multihashing-async/src/utils.js:8:7)
      at Immediate.<anonymous> (node_modules/async/internal/setImmediate.js:27:16)

@victorb victorb removed their request for review April 26, 2019 13:11
@momack2 momack2 added this to In Progress in ipfs/js-ipfs May 10, 2019
@momack2 momack2 added this to In Progress in ipfs/js-waffle May 10, 2019
@alanshaw
Copy link
Contributor

alanshaw commented Jul 5, 2019

@lidel can we get this fixed up please? 🙏

lidel added 2 commits July 9, 2019 13:09
Adds tests to guard against issue described in
ipfs-inactive/js-ipfs-http-client#875

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
lidel added a commit to lidel/js-ipfs that referenced this pull request Jul 9, 2019
Old version returned indirect pin
when `pin ls -t direct <path>` was executed.

This fixes filtering and adds necessary tests.

It also tweaks error handling to match behavior
from go-ipfs/js-ipfs-http-client and pass interop tests
from ipfs-inactive/interface-js-ipfs-core#375

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
@lidel
Copy link
Contributor Author

lidel commented Jul 9, 2019

@alanshaw aye! rebased & updated this PR. The latest js-ipfs-http-client with go-ipfs will pass it out of the box, js-ipfs will pass when fixes from ipfs/js-ipfs#2228 are merged ✨

@alanshaw alanshaw merged commit be72ed6 into master Jul 16, 2019
@alanshaw alanshaw deleted the fix/pin-ls-opts branch July 16, 2019 15:42
alanshaw pushed a commit to ipfs/js-ipfs that referenced this pull request Jul 17, 2019
### Summary

This PR fixes filtering, improves interop with go-ipfs and adds missing tests for `pin ls`

### Details

Old version returned indirect pin when `pin ls -t direct <path>` was executed.

This PR also tweaks error handling to match behavior from go-ipfs/js-ipfs-http-client and pass improved interop tests added in ipfs-inactive/interface-js-ipfs-core#375

I've added some inline comments, hope it helps in review.

### Related

- Improved `pin ls` interop tests: ipfs-inactive/interface-js-ipfs-core#375 
  (this PR is not blocked by interop tests, old ones were less strict)
- We need this fix for embedded js-ipfs in Brave 🦁 ipfs/ipfs-companion#716

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
@hsanjuan hsanjuan removed this from In Progress in ipfs/js-ipfs Apr 27, 2020
@hsanjuan hsanjuan removed this from In Progress in ipfs/js-waffle Apr 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants