sync_with_ping() currently returns false if the timeout expires, and it is the caller's responsibility to fail the test. However, none of the tests currently assert on sync_with_ping()'s return code. This commit adds an assert to sync_with_ping so the test will fail if the timeout expires.
This commit also removes all the duplicate implementations of sync_with_ping() from the individual tests.
~Only the second commit here needs to be reviewed. The first commit https://github.com/bitcoin/bitcoin/commit/159fe88abfadf67410578c145e631819cf50b660 is #10109.~ EDIT: #10109 is now merged.
EDIT: The first commit in this PR ("Add send_await_disconnect() method to p2p-compactblocks.py") is a test case bug fix that needs to be merged before merging the sync_with_ping() change
Should fix the intermittent failure reported here: #10073 (comment)
sync'ing and pinging @sdaftuar