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

Function golden_strict_tuple_format

nodedb-strict/src/encode.rs:624–663  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

622 /// schema_version u32 at [5..9].
623 #[test]
624 fn golden_strict_tuple_format() {
625 let schema = crm_schema();
626 let encoder = TupleEncoder::new(&schema);
627 let values = vec![
628 Value::Integer(1),
629 Value::String("A".into()),
630 Value::String("a@b.com".into()),
631 Value::Decimal(rust_decimal::Decimal::ZERO),
632 Value::Bool(false),
633 ];
634 let tuple = encoder.encode(&values).unwrap();
635
636 // Magic at [0..4]: "NDST" LE = 0x5453_444E.
637 assert_eq!(
638 &tuple[0..4],
639 &0x5453_444Eu32.to_le_bytes(),
640 "magic mismatch"
641 );
642 assert_eq!(&tuple[0..4], b"NDST", "magic bytes mismatch");
643
644 // FORMAT_VERSION == 1 at [4].
645 assert_eq!(tuple[4], FORMAT_VERSION, "format_version mismatch");
646 assert_eq!(tuple[4], 1u8, "expected FORMAT_VERSION == 1");
647
648 // schema_version u32 LE at [5..9].
649 let schema_ver = u32::from_le_bytes([tuple[5], tuple[6], tuple[7], tuple[8]]);
650 assert_eq!(
651 schema_ver, 1u32,
652 "schema_version must be 1 for version-1 schema"
653 );
654
655 // null bitmap at [9]: no nulls → 0.
656 assert_eq!(tuple[9], 0u8, "expected no null bits");
657
658 // Tuple must be longer than the 10-byte header.
659 assert!(
660 tuple.len() > 10,
661 "tuple must contain fixed/variable data after header"
662 );
663 }
664}

Callers

nothing calls this directly

Calls 2

crm_schemaFunction · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected