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:539–567  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

537
538 #[test]
539 fn test_session_event_key_ordering() {
540 // Keys for the same provenance_id must sort by seq in lexicographic
541 // (B-tree) order across the full u64 range. Big-endian encoding
542 // guarantees this: the most-significant byte comes first, so byte-wise
543 // comparison matches numeric comparison for all values.
544 let k1 = encode_session_event_key(5, 0);
545 let k2 = encode_session_event_key(5, 1);
546 let k3 = encode_session_event_key(5, 100);
547 let k4 = encode_session_event_key(6, 0);
548
549 assert!(k1 < k2);
550 assert!(k2 < k3);
551 assert!(k3 < k4, "different provenance_id sorts after");
552
553 // Boundary: seq=255 (single-byte max) vs seq=256 (spills into second byte).
554 // With big-endian encoding this must sort correctly.
555 let k_255 = encode_session_event_key(5, 255);
556 let k_256 = encode_session_event_key(5, 256);
557 assert!(
558 k_255 < k_256,
559 "seq=255 must sort before seq=256 (byte-spill boundary)"
560 );
561
562 // seq=256 on provenance_id=5 must still sort before provenance_id=6.
563 assert!(
564 k_256 < k4,
565 "seq=256 on provenance_id=5 must sort before provenance_id=6"
566 );
567 }
568
569 #[test]
570 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