Skip to content

Commit 2c4eb0a

Browse files
committed
tests: socket_comms: test broadcast without clients
Ensure that the local server can broadcast to the multicast group even if there are no clients connected. This ensures the gateway doesn't crash before any client tools are connected. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent 1c6c2e5 commit 2c4eb0a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/test_socket_comms.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,17 @@ def test_socket_comms():
1212
multicast_addr = comms.default_multicast_address()
1313
# Increment port by 1 so we can run the tests in parallel with a real instance
1414
test_addr = (multicast_addr[0], multicast_addr[1] + 1)
15+
16+
# Create the server first
1517
server = comms.LocalServer(test_addr)
18+
19+
# Send a message before any client is connected
20+
broadcast_msg = comms.ClientNotificationObservedDevices({})
21+
server.broadcast(broadcast_msg)
22+
23+
# Create a client that receives from the server, shouldn't receive the broadcast message
1624
client = comms.LocalClient(test_addr)
25+
assert client.receive() is None
1726

1827
# Send request to server
1928
request = comms.GatewayRequestCommsCheck()

0 commit comments

Comments
 (0)