holepunchto / hyperswarm

A distributed networking stack for connecting peers.
https://docs.holepunch.to
MIT License
1.03k stars 84 forks source link

Test swarm.flush() behaviour #155

Closed HDegroote closed 6 months ago

HDegroote commented 8 months ago

Includes a failing test on swarm.flush() behaviour, and another one on the more low-level .flushed() behaviour on the result of swarm.join()

There's some odd timing thing going on, but it might not be relevant. In the swarm test, awaiting a setImmediate does not fix the failing test, but awaiting a setTimeout(0) does fix it. For the more low-level test, both setImmediate and setTimeout(0) fail (waiting a longer time does make it pass)

This behaviour started between now and 7 days ago, so I think something must have changed in the dependencies (no real changes in hyperswarm since then)

The expected behaviour is in fact that the last to flush has a connection (swarm2 in the tests), but there's no guarantee on swarm1 already having the connection.

The test is now updated to test the expected behaviour