Closed adrianmcli closed 6 years ago
- Can you point me towards specific examples or documentation on how to do read/write/predictUri with IPFS? I haven't really worked with IPFS before and I'm not sure where to start. The terminology is really throwing me for a loop.
predictUri
should be the same as the stubread
and write
are concerned, I believe you have to use one of the JS IPFS libraries or this "mini" wrapper https://github.com/SilentCicero/ipfs-mini
- Could you help me scope out what tests and how they should be written?
I think for this, unit tests won't be so important, because mostly the module is just a wrapper around whatever IPFS lib you're using. I think a better strategy would be to make integration tests in src/storage/ipfs/test
that instantiate EthPM and then use the IPFS lib to verify the contents are getting written.
For these, you might emulate these main integration tests: https://github.com/ethpm/ethpm.js/blob/master/src/test/ethpm.ts
- I have the four .ts files for each of the functions, but I'm not sure how to connect them to the rest of the library.
Does the export
keyword work? I'd say look here for comparison: https://github.com/ethpm/ethpm.js/blob/master/test/stub/storage/index.ts
- Finally, let me know if I'm on track or further guidance if I am significantly off track.
Looks on-track to me!
Thanks, I'm going to turn your reply into action points for me:
predictUri
from stubread
with ~https://github.com/SilentCicero/ipfs-mini~ https://github.com/ipfs/js-ipfs-apiwrite
with ~https://github.com/SilentCicero/ipfs-mini~ https://github.com/ipfs/js-ipfs-apisrc/storage/ipfs/test
that instantiate EthPM w/ IPFS options (ref)Just an update, currently having a problem running IPFS for the integration test. I did a git bisect
and it seems the problem was introduced in this commit:
f0953498a97bfb51bac69762f5cc9c8f8e668b5d is the first bad commit
commit f0953498a97bfb51bac69762f5cc9c8f8e668b5d
Author: g. nicholas d'andrea <gnidan@users.noreply.github.com>
Date: Wed Aug 22 19:39:59 2018 -0400
Add IPFS hash generation
- Use technique described at https://stackoverflow.com/a/51304779
- Test that piper-coin's hash for standard-token matches ours
(Adding this now to start building stubbed IPFS resolver)
I think either ipfs-unixfs
or ipld-dag-pb
is causing issues with the dependency tree and it ends up messing with something that ipfs
is using. I need to look into this further if I am going to be able to do the integration test.
@gnidan
Here is a test script I use to see if it works:
// script.js
const IPFSFactory = require("ipfsd-ctl");
const f = IPFSFactory.create({ type: "js" });
f.spawn((err, ipfsd) => {
console.log(err);
console.log(ipfsd);
ipfsd.stop()
});
And I run it simply by executing node script.js
.
Here are the steps you can take to replicate the problem on your computer:
Check out this commit: https://github.com/ethpm/ethpm.js/commit/6d743fe44c2de9c5aa01c658e9499938348ba04d
Wipe your node modules rm -rf node_modules
and then yarn add ipfs ipfsd-ctl
Try the script node script.js
and see that it works fine (i.e. logs out an object, no error)
Check out this commit: https://github.com/ethpm/ethpm.js/commit/f0953498a97bfb51bac69762f5cc9c8f8e668b5d
Repeat steps 2 and 3, note that an error is now thrown
Starting this PR for easy reference. Will eventually fix #3.
@gnidan I need a bit of guidance here, I've got a bunch of questions.
Questions
I've noted each question as a TODO inside the diff (feel free to leave line comments), but is also summarized here:
Can you point me towards specific examples or documentation on how to do
read
/write
/predictUri
with IPFS? I haven't really worked with IPFS before and I'm not sure where to start. The terminology is really throwing me for a loop.Could you help me scope out what tests and how they should be written?
I have the four
.ts
files for each of the functions, but I'm not sure how to connect them to the rest of the library.For the(fixed w/ simpleread
function test, I need to be able to grab the value inside of the Maybe context. In Haskell, I would use pattern matching for this. I'm not sure how I would do this with Typescript.undefined
check)Finally, let me know if I'm on track or further guidance if I am significantly off track.