Skip to content

Commit 71c410e

Browse files
committed
add test for duplicate answers
1 parent fb529bc commit 71c410e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/test_handlers.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,3 +1122,24 @@ async def test_guard_against_low_ptr_ttl():
11221122
assert incoming_answer_normal.ttl == const._DNS_OTHER_TTL
11231123
assert zc.cache.async_get_unique(good_bye_answer) is None
11241124
await aiozc.async_close()
1125+
1126+
1127+
@pytest.mark.asyncio
1128+
async def test_duplicate_answers_in_packet():
1129+
"""Ensure we do not throw an exception when there are duplicate records in a packet."""
1130+
aiozc = AsyncZeroconf(interfaces=['127.0.0.1'])
1131+
zc = aiozc.zeroconf
1132+
answer_with_normal_ttl = r.DNSPointer(
1133+
"myservicelow_tcp._tcp.local.",
1134+
const._TYPE_PTR,
1135+
const._CLASS_IN | const._CLASS_UNIQUE,
1136+
const._DNS_OTHER_TTL,
1137+
'normal.local.',
1138+
)
1139+
response = r.DNSOutgoing(const._FLAGS_QR_RESPONSE)
1140+
response.add_answer_at_time(answer_with_normal_ttl, 0)
1141+
response.add_answer_at_time(answer_with_normal_ttl, 0)
1142+
response.add_answer_at_time(answer_with_normal_ttl, 0)
1143+
incoming = r.DNSIncoming(response.packets()[0])
1144+
zc.record_manager.async_updates_from_response(incoming)
1145+
await aiozc.async_close()

0 commit comments

Comments
 (0)