Previously, wait_for_getdata only looked for the presence of a recent "getdata" message. Additionally checking the object hashes inside the message should make tests involving wait_for_getdata more robust.
p2p_sendheaders.py already overrides wait_for_getdata do this check; we can use the same approach consistently across all tests that call wait_for_getdata.
This PR is progress towards #18614 , but closing that issue would also involve some additional changes to wait_for_getheaders.