Added heartbeat return on peer.py test

This commit is contained in:
2026-08-05 12:00:55 +01:00
parent f3b1a537f0
commit 6ec3ad6577
2 changed files with 6 additions and 1 deletions
+5 -1
View File
@@ -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: