@@ -389,7 +389,7 @@ def test_recent_packets_miss_with_small_now_is_not_suppressed(zc: Zeroconf) -> N
389389 """A cache miss must not trigger suppression when `now` is below the suppression interval."""
390390 # time.monotonic() can start near zero on freshly booted systems, so
391391 # `now - _DUPLICATE_PACKET_SUPPRESSION_INTERVAL` is negative for the
392- # first second of process lifetime. A 0.0 default on the recency
392+ # first interval of process lifetime. A 0.0 default on the recency
393393 # dict would let any negative `now - INTERVAL` satisfy the compare
394394 # and suppress legitimate traffic.
395395 zc .registry .async_add (
@@ -425,3 +425,22 @@ def handle_query_or_defer(
425425 with patch .object (listener , "handle_query_or_defer" ) as _handle_query_or_defer :
426426 listener ._process_datagram_at_time (False , len (packet ), 0.0 , packet , addrs )
427427 _handle_query_or_defer .assert_called_once ()
428+
429+
430+ def test_repeated_announcement_under_one_second_is_processed (zc : Zeroconf ) -> None :
431+ """An announcement repeated a little under a second later is not dropped as a duplicate."""
432+ listener = _listener .AsyncListener (zc )
433+ listener .transport = MagicMock ()
434+ response = r .DNSOutgoing (const ._FLAGS_QR_RESPONSE | const ._FLAGS_AA )
435+ response .add_answer_at_time (
436+ r .DNSAddress ("device.local." , const ._TYPE_A , const ._CLASS_IN , 120 , b"\x7f \x00 \x00 \x01 " ), 0
437+ )
438+ packet = response .packets ()[0 ]
439+ addrs = ("1.2.3.4" , 5353 )
440+
441+ now = current_time_millis ()
442+ listener ._process_datagram_at_time (False , len (packet ), now , packet , addrs )
443+ listener ._process_datagram_at_time (False , len (packet ), now + 5 , packet , addrs )
444+ assert listener .last_time == now
445+ listener ._process_datagram_at_time (False , len (packet ), now + 926 , packet , addrs )
446+ assert listener .last_time == now + 926
0 commit comments