From 6ec3ad6577af169b694ae1e5a3a51bad15755903 Mon Sep 17 00:00:00 2001 From: Hector van der Aa Date: Wed, 5 Aug 2026 12:00:55 +0100 Subject: [PATCH] Added heartbeat return on peer.py test --- src/dynalab_core/protocols/endpoint.py | 1 + test/manual/peer.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dynalab_core/protocols/endpoint.py b/src/dynalab_core/protocols/endpoint.py index 39dc6f1..acd15c1 100644 --- a/src/dynalab_core/protocols/endpoint.py +++ b/src/dynalab_core/protocols/endpoint.py @@ -177,6 +177,7 @@ class ConnectorEndpoint: first_received = True if received.return_timestamp is not None: last_recieved = received.return_timestamp + log.debug("Received heartbeat") if not first_received: if ctr > round( diff --git a/test/manual/peer.py b/test/manual/peer.py index 11b83b5..f49c901 100644 --- a/test/manual/peer.py +++ b/test/manual/peer.py @@ -1,5 +1,6 @@ import asyncio import logging +from time import monotonic from uuid import uuid4 from dynalab_core.protocols.packets import ProtocolMessage @@ -9,6 +10,7 @@ from dynalab_core.protocols.common import VersionDescriptor from dynalab_core.protocols.constants import PROTOCOL_VERSION from dynalab_core.protocols.json.wire import read_message, write_message from dynalab_core.protocols.packets.handshake import ConnectorHello, DynaLabHello +from dynalab_core.protocols.packets.heartbeat import Heartbeat CONNECTOR_VERSION = VersionDescriptor(type="alpha", major=0, minor=0, patch=1) @@ -57,7 +59,9 @@ async def main() -> None: try: while True: message = await read_message(reader) - log.info(message) + if isinstance(message, Heartbeat): + message.return_timestamp = round(monotonic() * 1000) + await write_message(writer, message) except KeyboardInterrupt: return finally: