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

Function test_validate_leaf_parent

atomic-core/src/crdt/apply/leaf.rs:1049–1078  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1047
1048 #[test]
1049 fn test_validate_leaf_parent() {
1050 let mut txn = MockTxn::new();
1051 let mut context = ApplyContext::new(ApplyOptions::default());
1052 let branch_id = create_test_branch(&mut txn, 1, 0);
1053 let leaf_id = LeafId::new(NodeId::new(1), 0);
1054
1055 // Create a leaf
1056 let insert_op = LeafOp::Insert {
1057 after: None,
1058 kind: TokenKind::Word,
1059 content: b"hello".to_vec(),
1060 };
1061 apply_leaf_op(
1062 &mut txn,
1063 &mut context,
1064 branch_id,
1065 leaf_id,
1066 &insert_op,
1067 b"hello",
1068 )
1069 .unwrap();
1070
1071 // Should pass for correct branch
1072 validate_leaf_parent(&txn, leaf_id, branch_id).unwrap();
1073
1074 // Should fail for wrong branch
1075 let wrong_branch = BranchId::new(NodeId::new(99), 0);
1076 let result = validate_leaf_parent(&txn, leaf_id, wrong_branch);
1077 assert!(result.is_err());
1078 }
1079}

Callers

nothing calls this directly

Calls 4

create_test_branchFunction · 0.85
validate_leaf_parentFunction · 0.85
apply_leaf_opFunction · 0.70
unwrapMethod · 0.45

Tested by

no test coverage detected