feat(pm3py): add Proxmark3.sync() for REPL/script usage without async boilerplate
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user