Lib_p2p: Fix the maintenance triggers and add unit tests
Context
This MR adds two test to make sure the maintenance is correctly triggered when the node has too many or too few connections. It also moves two p2p events to the maintenance module and adds two simple events to the p2p_connect_handler
We also fix a minor problem in the maintenance that did not allow the connect_handler to trigger the maintenance while creating a new connection. This should provide a more responsive maintenance that will be activated proactively by the connect_handler and not passively by a timeout.
This MR is based on https://gitlab.com/nomadic-labs/tezos/-/merge_requests/187 (notice that this MR was never merged on master )
Fix:
Manually testing the MR
dune exec src/lib_p2p/test/test_p2p_maintenance.exe
cat _build/_tests/tezos-p2p/p2p-maintenance.000.output
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Julien