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

Function capability_bits_negotiated

nodedb/tests/native_protocol.rs:328–362  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

326/// that the server supports.
327#[tokio::test]
328async fn capability_bits_negotiated() {
329 let server = NativeTestServer::start().await;
330
331 // Request a subset of known capabilities.
332 let client_caps = CAP_STREAMING | CAP_FTS | CAP_SPATIAL;
333 let hello = HelloFrame {
334 proto_min: 1,
335 proto_max: 1,
336 capabilities: client_caps,
337 };
338 let result = do_handshake(server.addr, &hello).await;
339 server.shutdown().await;
340
341 let (_stream, ack) = result.expect("handshake ok");
342
343 // Server must advertise at least one capability bit.
344 assert_ne!(
345 ack.capabilities, 0,
346 "server must advertise at least one capability"
347 );
348
349 // The echoed bits must be a subset of what the client offered.
350 let intersection = ack.capabilities & client_caps;
351 assert_ne!(
352 intersection, 0,
353 "at least one capability bit must be in the intersection"
354 );
355
356 // CAP_MSGPACK is defined but was not in client_caps — server does not set it.
357 let rejected = CAP_MSGPACK & ack.capabilities & !client_caps;
358 assert_eq!(
359 rejected, 0,
360 "server must not set bits the client did not request"
361 );
362}
363
364/// Max frame enforcement: sending a frame whose length prefix exceeds 16 MiB
365/// causes the server to send a typed error response and close the connection.

Callers

nothing calls this directly

Calls 3

do_handshakeFunction · 0.85
shutdownMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected