Skip to main content

raydriver.core.transport

MockTransport​

An in-memory byte transport for tests.

Feed bytes to the session with push() (as if the device had sent them), inspect everything the session sent with sent(), and simulate link state with set_connected() / set_write_error().

is_connected​

is_connected: bool

True while the transport link is open (i.e. a session connected through this mock).

clear_sent()​

clear_sent() -> None

Clear the recorded sent bytes.

ParameterTypeDescription
ReturnsNone

push()​

push(data: Sequence[int]) -> None

Deliver bytes to the session as if the device sent them.

ParameterTypeDescription
dataSequence[int]
ReturnsNone

sent()​

sent() -> list[bytes]

All bytes written to the device so far.

ParameterTypeDescription
Returnslist[bytes]

set_connected()​

set_connected(connected: bool) -> None

Simulate connect/disconnect of the physical link.

ParameterTypeDescription
connectedbool
ReturnsNone

set_write_error()​

set_write_error(message: Optional[str] = None) -> None

Fail subsequent writes with this message (and mark the link down), simulating an unplugged cable.

ParameterTypeDescription
messageOptional[str] = None
ReturnsNone

take_new_sent()​

take_new_sent() -> list[bytes]

Writes recorded since the previous call (or the last clear_sent): a monotonic cursor, so clearing the log never skips or replays chunks. This is what device emulators should consume.

ParameterTypeDescription
Returnslist[bytes]