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

Proposed example for IPNS publish interop (address questions in Discuss) #3166

Closed
wants to merge 18 commits into from

Conversation

DougAnderson444
Copy link
Contributor

@DougAnderson444 DougAnderson444 commented Jul 13, 2020

Hi everybody! Please bear with me, this is my first pull request into the IPFS repo, I apologize in advance if I mess up somehow!

Context for this PR:

This is a proposed example for the /examples/ folder for how to ipfs.name.publish in js-ipfs and have that ipns record pubsub'd over to a friendly neighborhood go-ipfs node to get recorded on the DHT.

Essentially, based on what was posted in the discuss, it still took me weeks to get this working, hopefully we can save others' time with an example? The good news is, it seems to work with both self keys and imported custom keys (the topics of the discussions below). [Edit: After fixes to my experiments, I discovered the resolve on custom keys was still failing (see #6360)]

Maybe this belongs in an "interop" example folder, but I didn't see one so I put it in js-http-client.

Relevant discussion,

I think an example like this is needed, based on seeing questions:
in Discuss cant-access-published-ipns-record-config-problem/5476/18 and
in Dicuss ipns-not-resolvable-from-other-node/8624/2 and
issue #6360 (still not resolved, I was premature on this one).

Stakeholders linked/mentioned

@vasco-santos and @aschmahmann have been great at fielding this question more than once, so I know it's not just me trying to get this to work outside the tests.

Thanks for coding such a great project!

@achingbrain
Copy link
Member

This is amazing - it'll be a great help for people in the future, thanks so much. Could you please:

  1. Move the example to the root /examples folder in this repo
  2. Change the references to https://github.com/ipfs/js-ipfs-http-client to https://github.com/ipfs/js-ipfs and reference the /packages/ipfs-http-client path within the repo where necessary
  3. Add a test to prevent regressions (see other test files in /examples/* for how they work, for example the circuit-relay test does similar things to what would be necessary - spins up an external IPFS node and then spawns a browser and does some interacting)
    • The source for the test runner is here
    • You may need to temporarily add the examples to lerna.json and run npm run reset && npm i in the repo root to make sure everything is symlinked correctly, see .travis.yml for what happens in CI when the examples are tested

@DougAnderson444
Copy link
Contributor Author

DougAnderson444 commented Jul 15, 2020

Ok, I'll give it a shot!

  • move to /examples folder
  • Change the references to https://github.com/ipfs/js-ipfs-http-client to https://github.com/ipfs/js-ipfs
  • Reference the /packages/ipfs-http-client path within the repo
  • Add some tests

@achingbrain
Copy link
Member

I've added tests to all the existing http client examples - they now live under /examples/http-client-* so it should hopefully be clear how to finish this off now.

@DougAnderson444
Copy link
Contributor Author

DougAnderson444 commented Jul 17, 2020

Thanks @achingbrain, I started to write the test but was just scratching my head as to how to run them.
When I run npm run test in the /examples/browser-ipns-publish folder to see if my test even works, I get 'test-ipfs-example' is not recognized as an internal or external command so I am trying to figure out how test-ipfs-example gets called...

(I did run npm i on the root folder, so I am presuming all symlinks that needed to be created were created?)

@achingbrain
Copy link
Member

There was a bug in the .travis.yml file that was stopping the examples build passing when a PR only made changes to that directory - it's fixed now, could you please merge master into this branch?

@achingbrain
Copy link
Member

I started to write the test but was just scratching my head as to how to run them

You need to declare test-ipfs-example as a dev dependency of your example, along with everything else required in the test file, then (if you haven't already) run the npx json... commands in .travis.yml to add the examples to the lerna config, then run npm run reset && npm i from the root of the repo and the command to build bundles for ipfs-http-client.

After all that you should be able to run npm test in the folder your example is in.

@DougAnderson444
Copy link
Contributor Author

DougAnderson444 commented Jul 18, 2020

Ok, all is set with the above instructions, but then something goes wrong resolving the chromedriver

An error occurred while trying to start ChromeDriver: cannot resolve path: 
"C:\Users\Documents\js-ipfs\examples\test-ipfs-example\node_modules\.bin\chromedriver".
Please check that the "webdriver.server_path" config property is set correctly.

Config is fine, the file is there.

Note: I'm using a Windows machine, and that's already caused some workaround issues, I wonder if it's linked to this too as it's a shell script? For example, I had to add the case for the folder slashes in the other direction in test.js:

  if (dir.includes('examples/browser-') || dir.includes('examples\\browser-') ) 

I'll see if I can figure a workaround, but any tips are time saving and greatly appreciated!

Otherwise, I will just write the test as best I can, and have someone else run it if this is too much headache :/

Edit: Found a workaround for windows which should do the trick.

@DougAnderson444
Copy link
Contributor Author

@achingbrain Alex, I think these tests are ready to be checked, but I'm having one heck of a frustrating time with multiple test env issues on my machine. If possible, could you run them to verify? I've gone around in circles so many times I think I'm at a stopping point.

@DougAnderson444 DougAnderson444 marked this pull request as ready for review August 3, 2020 15:31
@jacobheun
Copy link
Contributor

Closing in favor of #3207 where this is being continued.

@jacobheun jacobheun closed this Aug 6, 2020
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.

3 participants