fix p2p max_peers_connected_works
test
#1002
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We've been having certain issues with this test especially in the CI,
here's the analysis and the fix.
First problem is the assertion put on the swarm itself instead of our PeerManager:
While generally this should not return more peers than allowed, one of the reasons we have PeerManager is to actually contain number of peers connected logic, so moving the assertion to
should suffice since PeerManager is the one disconnecting surplus peers.
Other, and bigger, issue with the test was the amount of simulated nodes we used in our example.
Having 100+ nodes running makes the test itself unnecessarily slow.
This became even more evident now that we made our Heartbeat protocol ask for a disconnect from a node that did not reply within 2 seconds with a Block Height. So nodes started disconnecting from each other and the test would never hit its exit point.
Actually there is no need to have that amount of nodes, instead same assertion can be achieved with a smaller amount, so I have decreased the amount of nodes in the test.