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

fix ping tests #1685

Merged
merged 2 commits into from
Nov 1, 2018
Merged

fix ping tests #1685

merged 2 commits into from
Nov 1, 2018

Conversation

daviddias
Copy link
Member

For #1684

@ghost ghost assigned daviddias Oct 31, 2018
@ghost ghost added the status/in-progress In progress label Oct 31, 2018
expect(res.result.Strings).to.be.eql([])
done()
})
})
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was no longer valid. I've checked go-ipfs and now it is indeed supposed for IPFS to return the list of peers we are pubsub'ing with when no topic is provided.

@daviddias
Copy link
Member Author

Seems there are still some more issues on ping :(

@daviddias
Copy link
Member Author

image

@@ -27,7 +27,8 @@ module.exports = function pingPullStream (self) {
if (err) {
log.error(err)
source.push(getPacket({ success: false, text: err.toString() }))
source.end(err)
source.push(err)
source.end()
Copy link
Member Author

Choose a reason for hiding this comment

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

This made the tests pass but I'm not 100% convinced this is exactly what we want.

Copy link
Member

Choose a reason for hiding this comment

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

We need to differentiate between a real failure (invalid peer ID) and unavailable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've separated the getPeer from the runPing steps

@daviddias daviddias requested a review from alanshaw October 31, 2018 13:21
@daviddias
Copy link
Member Author

After debugging a bit more, I really think the problem is with the tests themselves. https://github.com/ipfs/interface-ipfs-core/blob/master/js/src/ping/ping.js#L58-L64 seems to be an antipattern to me. We can't expect to have error and results all at the same time.

@daviddias
Copy link
Member Author

daviddias commented Oct 31, 2018

Now I also understand why people were reporting that Ping was not working because DHT is not available:

AssertionError: expected [Error: Error: DHT is not available] to not exist

It should instead say, that it couldn't find the Peer.

Error from go-ipfs

Error: Peer lookup error: routing: not found]

@daviddias
Copy link
Member Author

Almost there. last mile is figuring out while the error doesn't propagate to the tests when using core directly (ipfs-api over http-api is fine)

Test Node.js


  cli
    ping
      ✓ ping host (955ms)
      ✓ ping host with --n option (791ms)
      ✓ ping host with --count option (908ms)

  HTTP API
Swarm listening on /ip4/127.0.0.1/tcp/0/ws/ipfs/QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A
Swarm listening on /ip4/127.0.0.1/tcp/62841/ipfs/QmQ2zigjQikYnyYUSXZydNXrDRhBut2mubwJBaLXobMt3A
API listening on /ip4/127.0.0.1/tcp/62842
Gateway (read only) listening on /ip4/127.0.0.1/tcp/62843
Web UI available at http://127.0.0.1:62842/webui
    ## http-api spec tests
      /ping
        ✓ returns 400 if both n and count are provided
        ✓ returns 400 if arg is not provided
        ✓ returns 200 and the response stream with the ping result

  interface-ipfs-core over ipfs-api tests
    .ping
      ✓ should send the specified number of packets
      ✓ should fail when pinging a peer that is not available
      ✓ should fail when pinging an invalid peer Id
    .pingPullStream
      ✓ should send the specified number of packets over pull stream
      ✓ should fail when pinging an unknown peer over pull stream
      ✓ should fail when pinging an invalid peer id over pull stream
    .pingReadableStream
      ✓ should send the specified number of packets over readable stream
      ✓ should fail when pinging peer that is not available over readable stream
      ✓ should fail when pinging an invalid peer id over readable stream

  interface-ipfs-core tests
    .ping
Swarm listening on /ip4/127.0.0.1/tcp/62915/ipfs/QmeSfaoj3aAEJUH5T7hJ7ULu1evo8j1TewyQhzvPESfaR3
Swarm listening on /ip4/127.0.0.1/tcp/62917/ipfs/QmX98kZpNKipM1EifTj6wqsYS6mmAQX37oYNmVpWPz8dv3
      ✓ should send the specified number of packets
      1) should fail when pinging a peer that is not available
      2) should fail when pinging an invalid peer Id
    .pingPullStream
Swarm listening on /ip4/127.0.0.1/tcp/62924/ipfs/QmY31MzrqTECyDz1MBHWtdMc4DyDPAMvoTXfZSDtYvhQ7K
Swarm listening on /ip4/127.0.0.1/tcp/62928/ipfs/QmTttTG2nVztU7uw4Xq76qwZEQrQxvG5tnmR8Cw5bBQGXG
      ✓ should send the specified number of packets over pull stream
      3) should fail when pinging an unknown peer over pull stream
      4) should fail when pinging an invalid peer id over pull stream
    .pingReadableStream
Swarm listening on /ip4/127.0.0.1/tcp/62935/ipfs/QmVZaeQC65aPEpkrwEnp5SUsvdxXEph4168tfij6i3aFG2
Swarm listening on /ip4/127.0.0.1/tcp/62939/ipfs/QmPLxuVK8hqzdTV3RzZP8hdrChuykNXGuNqdoSFChg4iqs
      ✓ should send the specified number of packets over readable stream
      5) should fail when pinging peer that is not available over readable stream
      6) should fail when pinging an invalid peer id over readable stream

@@ -23,9 +24,19 @@ exports.get = {
handler: (request, reply) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@alanshaw @hugomrdias @achingbrain et al, can I get your eyes to go through this handler. This stream tagliatelle is a nightmare came true.

Copy link
Member

Choose a reason for hiding this comment

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

Stream tagliatelle - I’m going to use that one

Copy link
Member

@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.

Buffering isn’t ideal but it’ll do for now!

@daviddias daviddias merged commit 27d5a57 into master Nov 1, 2018
@ghost ghost removed the status/in-progress In progress label Nov 1, 2018
@daviddias daviddias deleted the fix-ping branch November 1, 2018 09:38
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