Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Tests for links as hashes #3

Merged
merged 4 commits into from
Apr 9, 2016
Merged

Conversation

nicola
Copy link
Member

@nicola nicola commented Apr 8, 2016

I created a new block called across linked objects,
inside this block there is another block where links are multihashes,
since in my view links could also be paths e.g.{name: {@link: /hash/person/name}} and I expect where links are paths to happen soon (I can just remove it for now)

The tests are not passing:

  • I am not sure how I can point directly to the hash of a string (see line 130 and 153)
  • if {about: {'@link': 'hash'}} and I look for /about, the link should be resolved, instead of returning {'@link': 'hash'}
  • same for friends/0/bob

(my reference spec is both the ipld one and my attempt for ip-paths)

@dignifiedquire
Copy link
Member

re 1: I am not sure that is possible with IPLD/cbor as I don't know if they actually allow anything else than a map at the top level

@nicola
Copy link
Member Author

nicola commented Apr 8, 2016

@dignifiedquire: I think that should be just an IPFS object (not an ipld one). It is just a hash that resolves to a file (although we need to figure out how to store numbers & co)

@dignifiedquire
Copy link
Member

You can just run ipld.multihash on any buffer to get a usable hash to simulate sth like that

@dignifiedquire
Copy link
Member

After rereading the spec @link only allows for merkle links in the /ipfs object space. So sth like QmSjjs../prop is a merkle path which is not allowed as a link.

@nicola
Copy link
Member Author

nicola commented Apr 8, 2016

@dignifiedquire thanks for this! My tests did not test this yet and I will remove the block then(I will address the need of this feature in a different place).

We haven't yet solved 2 (correct?)

@nicola
Copy link
Member Author

nicola commented Apr 8, 2016

I used your previous suggestion on just using ipld.multihash

        const alice = {
          name: {
            '@link': ipld.multihash(aliceName)
          },

I got:

1) node test blocks resolve across linked objects where links are multihashes resolves link to string:
     Uncaught AssertionError: expected { Object (@link) } to deeply equal 'Alice'
      at test/ipld-tests.js:162:31
      at access (src/resolve.js:19:14)
      at access (src/resolve.js:43:7)
      at src/resolve.js:30:9
      at src/ipld-service.js:65:14
      at BufferList._callback (node_modules/ipfs-blocks/src/block-service.js:41:9)
      at BufferList.end (node_modules/bl/bl.js:98:10)
      at ReadStream.onend (_stream_readable.js:498:10)
      at endReadableNT (_stream_readable.js:913:12)

@dignifiedquire
Copy link
Member

Just got word from @jbenet and merkle paths are allowed to, need to fix the resolver for that

@dignifiedquire dignifiedquire merged commit 3175afa into ipld:master Apr 9, 2016
@dignifiedquire
Copy link
Member

Merged and fixed all cases except for the string one, which will not work in this way and I don't think will be needed at this level as all ipfs objects at the end of the day will become IPLD objects anyway.

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