From 6d8dc1cc5fd79e6cb873814b789d88e81f9111fb Mon Sep 17 00:00:00 2001 From: "Steven B." <51370195+sdb9696@users.noreply.github.com> Date: Tue, 29 Oct 2024 16:21:24 +0000 Subject: [PATCH] Only send 20002 discovery request with key included (#1207) --- kasa/discover.py | 1 - kasa/tests/test_discovery.py | 7 +++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/kasa/discover.py b/kasa/discover.py index ade6a54a..3b8f7c44 100755 --- a/kasa/discover.py +++ b/kasa/discover.py @@ -276,7 +276,6 @@ class _DiscoverProtocol(asyncio.DatagramProtocol): if self.target in self.seen_hosts: # Stop sending for discover_single break self.transport.sendto(encrypted_req[4:], self.target_1) # type: ignore - self.transport.sendto(Discover.DISCOVERY_QUERY_2, self.target_2) # type: ignore self.transport.sendto(aes_discovery_query, self.target_2) # type: ignore await asyncio.sleep(sleep_between_packets) diff --git a/kasa/tests/test_discovery.py b/kasa/tests/test_discovery.py index a31ef836..0dc4e0d7 100644 --- a/kasa/tests/test_discovery.py +++ b/kasa/tests/test_discovery.py @@ -294,7 +294,7 @@ async def test_discover_send(mocker): assert proto.target_1 == ("255.255.255.255", 9999) transport = mocker.patch.object(proto, "transport") await proto.do_discover() - assert transport.sendto.call_count == proto.discovery_packets * 3 + assert transport.sendto.call_count == proto.discovery_packets * 2 async def test_discover_datagram_received(mocker, discovery_data): @@ -501,14 +501,13 @@ async def test_do_discover_drop_packets(mocker, port, do_not_reply_count): discovery_timeout=discovery_timeout, discovery_packets=5, ) - expected_send = 1 if port == 9999 else 2 - ft = FakeDatagramTransport(dp, port, do_not_reply_count * expected_send) + ft = FakeDatagramTransport(dp, port, do_not_reply_count) dp.connection_made(ft) await dp.wait_for_discovery_to_complete() await asyncio.sleep(0) - assert ft.send_count == do_not_reply_count * expected_send + expected_send + assert ft.send_count == do_not_reply_count + 1 assert dp.discover_task.done() assert dp.discover_task.cancelled()