"""River 3 tests using synthetic protobuf messages, not device captures. Field numbers/types follow ha-ef-ble's proto/pr705.proto DisplayPropertyUpload. The packet fixtures model the XOR framing used by upstream River 3 tests. """ import asyncio import importlib.util import struct from dataclasses import asdict from pathlib import Path from unittest.mock import AsyncMock import pytest from bmspy.classes import UPS from bmspy.ecoflow_bt import ( EcoFlowBTDevice, EcoFlowPacket, _EncFrameHelper, _State, _Type7Encryption, ) from bmspy.ecoflow_river3 import decode_river3_payload ADDRESS = "02:00:00:00:00:03" SERIAL = "R651TEST00000001" def varint(value): value &= (1 << 64) - 1 data = bytearray() while value > 127: data.append((value & 127) | 128) value >>= 7 data.append(value) return bytes(data) def integer(field, value): return varint(field << 3) + varint(value) def floating(field, value): return varint((field << 3) | 5) + struct.pack("