lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

relay_document.rs (792B)


      1 #![cfg(feature = "serde_json")]
      2 
      3 use radroots_events_codec::error::EventParseError;
      4 use radroots_events_codec::relay_document::decode::from_json;
      5 use radroots_events_codec::relay_document::encode::to_json;
      6 
      7 #[test]
      8 fn relay_document_roundtrip_json() {
      9     let input = r#"{"name":"relay","supported_nips":[1,2],"software":"radroots"}"#;
     10     let doc = from_json(input).unwrap();
     11     let output = to_json(&doc).unwrap();
     12 
     13     let v_in: serde_json::Value = serde_json::from_str(input).unwrap();
     14     let v_out: serde_json::Value = serde_json::from_str(&output).unwrap();
     15     assert_eq!(v_out, v_in);
     16 }
     17 
     18 #[test]
     19 fn relay_document_rejects_invalid_json() {
     20     let err = from_json("{").unwrap_err();
     21     assert!(matches!(
     22         err,
     23         EventParseError::InvalidJson("relay_document")
     24     ));
     25 }