refactor: test: use wait_for_getdata() in p2p_compactblocks.py
The method wait_for_getdata() was recently changed to be more precise by waiting for a specified list of hashes, instead of only matching any getdata message (see PR18690). This PR replaces the remaining occurences of manual inspection of last_messages with this call.
This is a backport of Core PR18756
Test Plan: test/functional/test_runner.py p2p_compactblocks
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D8974