()
| 543 | /// definition), proving the field is real — not silently dropped. |
| 544 | #[test] |
| 545 | fn default_kind_is_omitted_and_hash_stable() { |
| 546 | let n = node(); |
| 547 | assert_eq!(n.kind, "feature"); |
| 548 | |
| 549 | // Proof of byte-identity: an ordinary intent carries NO `kind` key, so |
| 550 | // its JSON (and every hash derived from it) matches the pre-`kind` |
| 551 | // fixture exactly. |
| 552 | let value = n.to_value(); |
| 553 | assert!( |
| 554 | value.as_object().unwrap().get("kind").is_none(), |
| 555 | "default kind must not appear in the canonical JSON" |
| 556 | ); |
| 557 | |
| 558 | let base_content = n.compute_content_hash(); |
| 559 | let base_substance = intent_substance_hash(&n); |
| 560 | |
| 561 | // Re-asserting the default kind changes nothing (still omitted). |
| 562 | let mut still_default = n.clone(); |
| 563 | still_default.kind = default_kind(); |
| 564 | assert_eq!(still_default.compute_content_hash(), base_content); |
| 565 | assert_eq!(intent_substance_hash(&still_default), base_substance); |
| 566 | |
| 567 | // A review kind IS serialized, and moves both hashes. |
| 568 | let mut review = n.clone(); |
| 569 | review.kind = "review".to_string(); |
| 570 | assert!(review.to_value().as_object().unwrap().get("kind").is_some()); |
| 571 | assert_ne!(review.compute_content_hash(), base_content); |
| 572 | assert_ne!(intent_substance_hash(&review), base_substance); |
| 573 | } |
| 574 | } |
nothing calls this directly
no test coverage detected