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

Function legacy_pristine

atomic-core/tests/merge_test.rs:24–47  ·  view source on GitHub ↗

A legacy pristine with a view, a registered change, graph edges and CRDT rows.

(path: &Path)

Source from the content-addressed store, hash-verified

22
23/// A legacy pristine with a view, a registered change, graph edges and CRDT rows.
24fn legacy_pristine(path: &Path) -> Hash {
25 let hash = Hash::of(b"legacy change");
26 let pristine = Pristine::open(path).unwrap();
27 let mut txn = pristine.write_txn().unwrap();
28 let mut view = txn.open_or_create_view("dev").unwrap();
29 let id = txn.register_change(&hash).unwrap();
30 txn.put_change(&mut view, id, &hash).unwrap();
31 txn.update_view(&view).unwrap();
32 txn.commit().unwrap();
33 drop(pristine);
34
35 let db = Database::open(path).unwrap();
36 let txn = db.begin_write().unwrap();
37 {
38 let mut graph = txn.open_multimap_table(GRAPH).unwrap();
39 graph.insert(&[1u8; 24], &[2u8; 24]).unwrap();
40 graph.insert(&[1u8; 24], &[3u8; 24]).unwrap();
41 graph.insert(&[4u8; 24], &[5u8; 24]).unwrap();
42 let mut trunks = txn.open_table(crdt::TRUNKS).unwrap();
43 trunks.insert(&[7u8; 12], b"trunk".as_slice()).unwrap();
44 }
45 txn.commit().unwrap();
46 hash
47}
48
49/// A legacy change store holding only provenance journal state, as in production.
50fn legacy_changes(path: &Path) {

Calls 11

openFunction · 0.85
write_txnMethod · 0.80
open_or_create_viewMethod · 0.80
register_changeMethod · 0.80
put_changeMethod · 0.80
update_viewMethod · 0.80
begin_writeMethod · 0.80
unwrapMethod · 0.45
commitMethod · 0.45
insertMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected