diff --git a/tests/environment_contract.py b/tests/environment_contract.py index d94566d..10639dc 100644 --- a/tests/environment_contract.py +++ b/tests/environment_contract.py @@ -109,8 +109,14 @@ def wait_ready(process: subprocess.Popen[str], port: int) -> None: if process.poll() is not None: raise AssertionError(process.stderr.read() if process.stderr else "stream exited") try: - urllib.request.urlopen(f"http://127.0.0.1:{port}/", timeout=0.2).read() - return + # listener-first startup: wait past the startup gate, not just + # for an answering socket — xrpc paths 503 as "starting" until + # storage is published, and this contract asserts on the auth + # layer behind that gate + body = urllib.request.urlopen(f"http://127.0.0.1:{port}/status", timeout=0.2).read() + if b"state starting" not in body: + return + time.sleep(0.025) except OSError: time.sleep(0.025) raise AssertionError(f"listener {port} did not become ready")