MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_json_frame

Function read_json_frame

nodedb/tests/startup_gate_native.rs:59–72  ·  view source on GitHub ↗

Read one native protocol frame from a stream (4-byte length prefix + payload).

(stream: &mut TcpStream)

Source from the content-addressed store, hash-verified

57
58/// Read one native protocol frame from a stream (4-byte length prefix + payload).
59async fn read_json_frame(stream: &mut TcpStream) -> Vec<u8> {
60 let mut len_buf = [0u8; 4];
61 stream
62 .read_exact(&mut len_buf)
63 .await
64 .expect("failed to read frame length");
65 let len = u32::from_be_bytes(len_buf) as usize;
66 let mut payload = vec![0u8; len];
67 stream
68 .read_exact(&mut payload)
69 .await
70 .expect("failed to read frame payload");
71 payload
72}
73
74#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
75async fn native_status_returns_ok_after_gateway_enable() {

Calls 2

expectMethod · 0.45
read_exactMethod · 0.45

Tested by

no test coverage detected