MCPcopy Create free account
hub / github.com/evilsocket/cake / test_batch_echo

Function test_batch_echo

cake-core/tests/protocol.rs:228–259  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226
227#[tokio::test]
228async fn test_batch_echo() {
229 let mock = MockWorker::bind().await;
230 let addr = mock.addr();
231 let worker = tokio::spawn(async move { mock.handle_one(None).await });
232
233 let (mut stream, _) = connect_and_handshake(addr, None).await;
234
235 let tensor = make_f16_tensor(&[1, 64]);
236 let orig_bytes: Vec<u8> = tensor.data().to_vec();
237 let batch = vec![
238 ("model.layers.0".into(), 0usize, 0usize),
239 ("model.layers.1".into(), 1, 1),
240 ];
241
242 Message::from_batch(&tensor, batch)
243 .to_writer(&mut stream)
244 .await
245 .unwrap();
246
247 let (_, resp) = Message::from_reader(&mut stream).await.unwrap();
248 match resp {
249 Message::Tensor(raw) => {
250 let recovered = raw.to_tensor(&Device::Cpu).unwrap();
251 assert_eq!(recovered.shape().dims(), &[1, 64]);
252 assert_eq!(recovered.data().to_vec(), orig_bytes);
253 }
254 other => panic!("expected Tensor, got {:?}", other),
255 }
256
257 drop(stream);
258 let _ = worker.await;
259}
260
261#[tokio::test]
262async fn test_multiple_sequential_ops() {

Callers

nothing calls this directly

Calls 8

connect_and_handshakeFunction · 0.85
addrMethod · 0.80
handle_oneMethod · 0.80
to_vecMethod · 0.80
dataMethod · 0.80
to_writerMethod · 0.80
to_tensorMethod · 0.80
make_f16_tensorFunction · 0.70

Tested by

no test coverage detected