@@ -448,7 +448,7 @@ def test_recent_packets_miss_with_small_now_is_not_suppressed(zc: Zeroconf) -> N
448448 """A cache miss must not trigger suppression when `now` is below the suppression interval."""
449449 # time.monotonic() can start near zero on freshly booted systems, so
450450 # `now - _DUPLICATE_PACKET_SUPPRESSION_INTERVAL` is negative for the
451- # first second of process lifetime. A 0.0 default on the recency
451+ # first interval of process lifetime. A 0.0 default on the recency
452452 # dict would let any negative `now - INTERVAL` satisfy the compare
453453 # and suppress legitimate traffic.
454454 zc .registry .async_add (
@@ -484,3 +484,22 @@ def handle_query_or_defer(
484484 with patch .object (listener , "handle_query_or_defer" ) as _handle_query_or_defer :
485485 listener ._process_datagram_at_time (False , len (packet ), 0.0 , packet , addrs )
486486 _handle_query_or_defer .assert_called_once ()
487+
488+
489+ def test_repeated_announcement_under_one_second_is_processed (zc : Zeroconf ) -> None :
490+ """An announcement repeated a little under a second later is not dropped as a duplicate."""
491+ listener = _listener .AsyncListener (zc )
492+ listener .transport = MagicMock ()
493+ response = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE | const ._FLAGS_AA )
494+ response .add_answer_at_time (
495+ r .DNSAddress ("device.local." , const ._TYPE_A , const ._CLASS_IN , 120 , b"\x7f \x00 \x00 \x01 " ), 0
496+ )
497+ packet = response .packets ()[0 ]
498+ addrs = ("1.2.3.4" , 5353 )
499+
500+ now = current_time_millis ()
501+ listener ._process_datagram_at_time (False , len (packet ), now , packet , addrs )
502+ listener ._process_datagram_at_time (False , len (packet ), now + 5 , packet , addrs )
503+ assert listener .last_time == now
504+ listener ._process_datagram_at_time (False , len (packet ), now + 926 , packet , addrs )
505+ assert listener .last_time == now + 926
0 commit comments