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:444–458  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

unwrapMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected