MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / decode_rejects_a_body_over_the_limit

Function decode_rejects_a_body_over_the_limit

atomic-objects/src/sync.rs:438–452  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

436
437 #[test]
438 fn decode_rejects_a_body_over_the_limit() {
439 // Compress 5000 bytes, then demand it decode within 1000 — the streaming
440 // guard must reject it as TooLarge rather than allocating the full output.
441 let pack = SyncPack {
442 objects: vec![ObjectRecord::new(
443 ObjectFamily::Change,
444 "k",
445 vec![7u8; 5000],
446 )],
447 refs: vec![],
448 };
449 let wire = pack.encode().unwrap();
450 let err = decode_with_limit::<SyncPack>(&wire, 1000).unwrap_err();
451 assert!(matches!(err, SyncError::TooLarge { limit: 1000 }));
452 }
453
454 #[test]
455 fn decode_rejects_garbage() {

Callers

nothing calls this directly

Calls 2

unwrapMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected