| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1066,6 +1066,19 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()): | |||
| 1066 | 1066 | "ash-2.local.", | |
| 1067 | 1067 | addresses=[socket.inet_aton("10.0.1.2")], | |
| 1068 | 1068 | ) | |
| 1069 | + # Wait for the browser's first startup query to land (with an empty | ||
| 1070 | + # cache) before registering — otherwise on fast loopback the register | ||
| 1071 | + # may finish before the first query fires, and answers[0] picks up | ||
| 1072 | + # the known PTR via RFC 6762 §7.1 known-answer suppression. | ||
| 1073 | + await asyncio.wait_for(got_query.wait(), 1) | ||
| 1074 | + # Snapshot the first query's answers and reset the captures so the | ||
| 1075 | + # subsequent assertions don't have to predict whether further startup | ||
| 1076 | + # queries fire in real time (before the manual time_changed_millis | ||
| 1077 | + # loop) or under mock time. | ||
| 1078 | + first_answers = answers[0] | ||
| 1079 | + packets.clear() | ||
| 1080 | + answers.clear() | ||
| 1081 | + got_query.clear() | ||
| 1069 | 1082 | task = await aio_zeroconf_registrar.async_register_service(info) | |
| 1070 | 1083 | await task | |
| 1071 | 1084 | loop = asyncio.get_running_loop() | |
@@ -1084,7 +1097,9 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()): | |||
| 1084 | 1097 | got_query.clear() | |
| 1085 | 1098 | assert not unexpected_ttl.is_set() | |
| 1086 | 1099 | ||
| 1087 | - assert len(packets) == _services_browser.STARTUP_QUERIES | ||
| 1100 | + # The first startup query was captured separately, so only the | ||
| 1101 | + # remaining STARTUP_QUERIES - 1 land here. | ||
| 1102 | + assert len(packets) == _services_browser.STARTUP_QUERIES - 1 | ||
| 1088 | 1103 | packets.clear() | |
| 1089 | 1104 | ||
| 1090 | 1105 | # Wait for the first refresh query | |
@@ -1098,12 +1113,12 @@ def send(out, addr=const._MDNS_ADDR, port=const._MDNS_PORT, v6_flow_scope=()): | |||
| 1098 | 1113 | assert len(packets) == 1 | |
| 1099 | 1114 | packets.clear() | |
| 1100 | 1115 | ||
| 1101 | - assert len(answers) == _services_browser.STARTUP_QUERIES + 1 | ||
| 1102 | - # The first question should have no known answers | ||
| 1103 | - assert len(answers[0]) == 0 | ||
| 1116 | + assert len(answers) == _services_browser.STARTUP_QUERIES | ||
| 1117 | + # The first question (captured separately) should have no known answers | ||
| 1118 | + assert len(first_answers) == 0 | ||
| 1104 | 1119 | # The rest of the startup questions should have | |
| 1105 | 1120 | # known answers | |
| 1106 | - for answer_list in answers[1:-2]: | ||
| 1121 | + for answer_list in answers[:-2]: | ||
| 1107 | 1122 | # Allow 0 or 1 answers due to random delays and timing | |
| 1108 | 1123 | assert len(answer_list) <= 1 | |
| 1109 | 1124 | # Once the TTL is reached, the last question should have no known answers | |
| Back | FazBrowse Home | New Git URL |
0 commit comments