[test] Fix intermittent timeouts in various functional tests
Summary:
Original PR message was "test: Fix intermittent timeout in p2p_permissions.py" but the impact is larger than this, notably rpc_net.py.
Pull request description:
The sync is based on `bytesrecv_per_msg["verack"]`. However, the bytes are counted before processing the message, so they are not sufficient to ensure the connection is fully up.
Backport of core#26854
Depends on D17530
Test Plan:
ninja check-functional
Reviewers: #bitcoin_abc, Fabien, PiRK
Reviewed By: #bitcoin_abc, Fabien, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D17531