This piece of code faces the following issues/challenges:
- The expected debug log line may be emitted while wait_until times out. Successive retries miss the log line because assert_debug_log does not look into the past.
- lambda: not self.can_find_proof_in_poll(...) is not expected to return immediately once the proof has finalized/stalled, making #1 worse.
- The retry loop may retry for reasons unrelated to its intended purpose.
- In the stalled proof check, the timeout is insufficient for TSAN.
This patch fixes all of these issues by replacing the complex retry loop with a dumb for loop that resides inside of the assert_debug_context. This ensures that the log will always be captured. The tradeoff is multiple calls to can_find_proof_in_poll, which gives a small hit to test timing (a few seconds in total).