From f1e12a8ac315c91bb62964bc6a87de33b636edf8 Mon Sep 17 00:00:00 2001 From: Teknique Date: Fri, 26 May 2023 18:29:06 -0700 Subject: [PATCH] More type testing. --- .../veilid_api/tests/test_serialize_json.rs | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/veilid-core/src/veilid_api/tests/test_serialize_json.rs b/veilid-core/src/veilid_api/tests/test_serialize_json.rs index 4cf44cba..1f9f28fe 100644 --- a/veilid-core/src/veilid_api/tests/test_serialize_json.rs +++ b/veilid-core/src/veilid_api/tests/test_serialize_json.rs @@ -11,14 +11,34 @@ pub async fn test_round_trip_peerinfo() { } pub async fn test_alignedu64() { - let a = AlignedU64::new(0x0123456789abcdef); + let orig = AlignedU64::new(0x0123456789abcdef); + let copy = deserialize_json(&serialize_json(orig)).unwrap(); - let b = serialize_json(a); - let c = deserialize_json(&b).unwrap(); + assert_eq!(orig, copy); +} - assert_ne!(a, c); +pub async fn test_fourcc() { + let orig = FourCC::from_str("D34D").unwrap(); + let copy = deserialize_json(&serialize_json(orig)).unwrap(); + + assert_eq!(orig, copy); +} + +pub async fn test_safetyspec() { + let orig = SafetySpec { + preferred_route: Some(CryptoKey::new(*b"thisISaKEYthat's32charsLONGitIS!")), + hop_count: 23, + stability: Stability::default(), + sequencing: Sequencing::default(), + }; + let copy = deserialize_json(&serialize_json(orig)).unwrap(); + + assert_eq!(orig, copy); } pub async fn test_all() { test_round_trip_peerinfo().await; + test_alignedu64().await; + test_fourcc().await; + test_safetyspec().await; }