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

Function test_session_event_key_ordering

atomic-core/src/change/session.rs:1283–1311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1281
1282 #[test]
1283 fn test_session_event_key_ordering() {
1284 // Keys for the same provenance_id must sort by seq in lexicographic
1285 // (B-tree) order across the full u64 range. Big-endian encoding
1286 // guarantees this: the most-significant byte comes first, so byte-wise
1287 // comparison matches numeric comparison for all values.
1288 let k1 = encode_session_event_key(5, 0);
1289 let k2 = encode_session_event_key(5, 1);
1290 let k3 = encode_session_event_key(5, 100);
1291 let k4 = encode_session_event_key(6, 0);
1292
1293 assert!(k1 < k2);
1294 assert!(k2 < k3);
1295 assert!(k3 < k4, "different provenance_id sorts after");
1296
1297 // Boundary: seq=255 (single-byte max) vs seq=256 (spills into second byte).
1298 // With big-endian encoding this must sort correctly.
1299 let k_255 = encode_session_event_key(5, 255);
1300 let k_256 = encode_session_event_key(5, 256);
1301 assert!(
1302 k_255 < k_256,
1303 "seq=255 must sort before seq=256 (byte-spill boundary)"
1304 );
1305
1306 // seq=256 on provenance_id=5 must still sort before provenance_id=6.
1307 assert!(
1308 k_256 < k4,
1309 "seq=256 on provenance_id=5 must sort before provenance_id=6"
1310 );
1311 }
1312
1313 #[test]
1314 fn test_session_todo_key_deterministic() {

Callers

nothing calls this directly

Calls 1

encode_session_event_keyFunction · 0.85

Tested by

no test coverage detected