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

Function replicated_entry_roundtrip

nodedb/src/control/wal_replication/tests.rs:9–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[test]
9fn replicated_entry_roundtrip() {
10 let entry = ReplicatedEntry::new(
11 1,
12 42,
13 ReplicatedWrite::PointPut {
14 collection: "users".into(),
15 document_id: "u1".into(),
16 value: b"alice".to_vec(),
17 },
18 );
19 let original_key = entry.idempotency_key;
20 assert_ne!(original_key, 0, "idempotency_key must be non-zero");
21
22 let bytes = entry.to_bytes();
23 let decoded = ReplicatedEntry::from_bytes(&bytes).unwrap();
24 assert_eq!(decoded.tenant_id, 1);
25 assert_eq!(decoded.vshard_id, 42);
26 assert_eq!(
27 decoded.idempotency_key, original_key,
28 "idempotency_key roundtrip"
29 );
30 match decoded.write {
31 ReplicatedWrite::PointPut {
32 collection,
33 document_id,
34 value,
35 } => {
36 assert_eq!(collection, "users");
37 assert_eq!(document_id, "u1");
38 assert_eq!(value, b"alice");
39 }
40 other => panic!("expected PointPut, got {other:?}"),
41 }
42}
43
44#[test]
45fn all_write_variants_serialize() {

Callers

nothing calls this directly

Calls 2

to_vecMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected