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

Swarm Tests - WIP #150

Merged
merged 2 commits into from
Sep 1, 2017
Merged

Swarm Tests - WIP #150

merged 2 commits into from
Sep 1, 2017

Conversation

victorb
Copy link
Contributor

@victorb victorb commented Aug 26, 2017

Not mergable yet

@victorb
Copy link
Contributor Author

victorb commented Aug 26, 2017

Depends on ipfs/js-ipfs#960

@victorb
Copy link
Contributor Author

victorb commented Aug 26, 2017

Two things I hit during writing these tests:

  • For some reason, we cannot listen to port 0 twice somehow... Having /ip4/127.0.0.1/tcp/0 is fine if it's just one time, but if we do the same, I would expect us to get assigned two random ports from the OS, but it only happens the first time, then the second listener is stuck on port 0
  • Calling ipfs.swarm.peers in the callback of ipfs.swarm.connect does not show the peer you just connected to. It seems there is some async task that happens in the background of ipfs.swarm.connect after the callback has been called, instead of waiting for the connection to be fully established.

@daviddias
Copy link
Contributor

For some reason, we cannot listen to port 0 twice somehow... Having /ip4/127.0.0.1/tcp/0 is fine if it's just one time, but if we do the same, I would expect us to get assigned two random ports from the OS, but it only happens the first time, then the second listener is stuck on port 0

That is strange. Can you replicate the same behaviour using just TCP sockets in a simple Node.js script?

Calling ipfs.swarm.peers in the callback of ipfs.swarm.connect does not show the peer you just connected to. It seems there is some async task that happens in the background of ipfs.swarm.connect after the callback has been called, instead of waiting for the connection to be fully established.

This should not be the case, but it certainly happens in the 'dialing dance' inside libp2p-swarm. This work -- https://github.com/libp2p/js-libp2p-swarm/issues/24 -- would solve this. Can you make sure to add a test for this case (a failing one) commented out and pointing to that issue so that we know what's going on?

(cb) => {
// Waiting to make sure nodes are connected
setTimeout(cb, 1000)
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary for nodeA.swarm.peers or for nodeB.swarm.peers?

src/swarm.js Outdated
// Need to explicitly declare the ports as 0 doesn't work with
// multiple swarm addresses apparently
// Not sure how to deal with the case if the ports are busy, this
// is introducing flakyness
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really weird to me. See #150 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test case to reproduce the issue: libp2p/js-libp2p-switch#227

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a TODO here and create an issue to track this so that we can merge this PR as it is now.

@victorb
Copy link
Contributor Author

victorb commented Aug 28, 2017

That is strange. Can you replicate the same behaviour using just TCP sockets in a simple Node.js script?

Made some small test program but no problem there. Made a test-case for libp2p-swarm though that is currently failing, you can see it here: libp2p/js-libp2p-switch#227

Guessing there is some de-duplication we're doing that removes the second one since it's exactly the same as the first address being added.

@daviddias
Copy link
Contributor

daviddias commented Sep 1, 2017

@victorbjelkholm can you confirm that:

@victorb
Copy link
Contributor Author

victorb commented Sep 1, 2017

@diasdavid yes to both of them

@daviddias daviddias merged commit b19c80f into master Sep 1, 2017
@daviddias daviddias deleted the swarm-tests branch September 1, 2017 09:02
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