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

Function depth_budget_is_enforced

atomic-repository/src/git_binding/pack.rs:1004–1018  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1002
1003 #[test]
1004 fn depth_budget_is_enforced() {
1005 let h1 = Hash::from_bytes([1u8; 32]);
1006 let h2 = Hash::from_bytes([2u8; 32]);
1007 let h3 = Hash::from_bytes([3u8; 32]);
1008 let h4 = Hash::from_bytes([4u8; 32]);
1009 // Chain of depth 4 against a budget of 3.
1010 let edges = HashMap::from([(h1, vec![h2]), (h2, vec![h3]), (h3, vec![h4]), (h4, vec![])]);
1011 let error = check_depth_and_cycles(&edges, 3).unwrap_err();
1012 assert!(
1013 matches!(error, BindingClosureError::ClosureTooDeep { .. }),
1014 "{error}"
1015 );
1016 // Within budget it passes.
1017 assert_eq!(check_depth_and_cycles(&edges, 4).unwrap(), 4);
1018 }
1019
1020 #[test]
1021 fn closure_root_mismatch_is_refused() {

Callers

nothing calls this directly

Calls 1

check_depth_and_cyclesFunction · 0.85

Tested by

no test coverage detected