feat(pm3py): add Proxmark3.sync() for REPL/script usage without async boilerplate

This commit is contained in:
michael
2026-03-16 00:09:14 -07:00
parent 8c0a57525a
commit 205e9b7993
2 changed files with 74 additions and 0 deletions

View File

@@ -52,6 +52,30 @@ def test_mf_rdbl_returns_hex():
assert result["raw"] == block
def test_sync_proxy():
"""Verify sync proxy wraps async calls."""
from pm3py.transport import PM3Response
from pm3py.client import _SyncProxy
pm3 = Proxmark3("/dev/null")
loop = asyncio.new_event_loop()
proxy = _SyncProxy(pm3, loop)
# Mock the transport on the command object
mock_transport = AsyncMock()
proxy._target.hw._t = mock_transport
ping_data = bytes(range(32))
mock_transport.send_ng.return_value = PM3Response(
cmd=Cmd.PING, status=0, reason=0, ng=True, data=ping_data)
# Call synchronously — no await needed
result = proxy.hw.ping(32)
assert result["success"] is True
assert result["length"] == 32
loop.close()
def test_firmware_probe_compatible():
"""Verify firmware probe populates FirmwareInfo on successful connect."""
pm3 = Proxmark3("/dev/null")