MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / basic_roundtrip

Function basic_roundtrip

nodedb-codec/src/crdt_compress.rs:254–280  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

252
253 #[test]
254 fn basic_roundtrip() {
255 let ops = vec![
256 CrdtOp {
257 lamport: 1,
258 actor_id: 100,
259 content: b"insert 'hello'".to_vec(),
260 },
261 CrdtOp {
262 lamport: 2,
263 actor_id: 100,
264 content: b"insert ' world'".to_vec(),
265 },
266 CrdtOp {
267 lamport: 3,
268 actor_id: 200,
269 content: b"delete [0..5]".to_vec(),
270 },
271 ];
272 let encoded = encode(&ops).unwrap();
273 let decoded = decode(&encoded).unwrap();
274
275 assert_eq!(decoded.len(), 3);
276 assert_eq!(decoded[0].lamport, 1);
277 assert_eq!(decoded[0].actor_id, 100);
278 assert_eq!(decoded[0].content, b"insert 'hello'");
279 assert_eq!(decoded[2].actor_id, 200);
280 }
281
282 #[test]
283 fn compression_with_many_ops() {

Callers

nothing calls this directly

Calls 2

encodeFunction · 0.70
decodeFunction · 0.70

Tested by

no test coverage detected