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

Source from the content-addressed store, hash-verified

776
777 #[test]
778 fn test_session_event_key_ordering() {
779 // Keys for the same provenance_id must sort by seq in lexicographic
780 // (B-tree) order across the full u64 range. Big-endian encoding
781 // guarantees this: the most-significant byte comes first, so byte-wise
782 // comparison matches numeric comparison for all values.
783 let k1 = encode_session_event_key(5, 0);
784 let k2 = encode_session_event_key(5, 1);
785 let k3 = encode_session_event_key(5, 100);
786 let k4 = encode_session_event_key(6, 0);
787
788 assert!(k1 < k2);
789 assert!(k2 < k3);
790 assert!(k3 < k4, "different provenance_id sorts after");
791
792 // Boundary: seq=255 (single-byte max) vs seq=256 (spills into second byte).
793 // With big-endian encoding this must sort correctly.
794 let k_255 = encode_session_event_key(5, 255);
795 let k_256 = encode_session_event_key(5, 256);
796 assert!(
797 k_255 < k_256,
798 "seq=255 must sort before seq=256 (byte-spill boundary)"
799 );
800
801 // seq=256 on provenance_id=5 must still sort before provenance_id=6.
802 assert!(
803 k_256 < k4,
804 "seq=256 on provenance_id=5 must sort before provenance_id=6"
805 );
806 }
807
808 #[test]
809 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