From b397b5c66b27a070a4871e67ebb948a0853187fb Mon Sep 17 00:00:00 2001 From: Teknique Date: Thu, 1 Jun 2023 13:57:18 -0700 Subject: [PATCH] Finish coverage of veilid_api::types --- .../veilid_api/tests/test_serialize_json.rs | 52 ++++++++++++++++++- .../src/veilid_api/types/app_message_call.rs | 10 ++-- 2 files changed, 55 insertions(+), 7 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 4afa633a..109fc6a6 100644 --- a/veilid-core/src/veilid_api/tests/test_serialize_json.rs +++ b/veilid-core/src/veilid_api/tests/test_serialize_json.rs @@ -20,6 +20,29 @@ pub async fn test_alignedu64() { assert_eq!(orig, copy); } +// veilid_api/types/app_messsage_call.rs + +pub async fn test_veilidappmessage() { + let orig = VeilidAppMessage { + sender: Some(fix_typedkey()), + message: b"Hi there!".to_vec(), + }; + let copy = deserialize_json(&serialize_json(&orig)).unwrap(); + + assert_eq!(orig, copy); +} + +pub async fn test_veilidappcall() { + let orig = VeilidAppCall { + sender: Some(fix_typedkey()), + message: b"Well, hello!".to_vec(), + id: AlignedU64::from(123), + }; + let copy = deserialize_json(&serialize_json(&orig)).unwrap(); + + assert_eq!(orig, copy); +} + // veilid_api/types/fourcc.rs pub async fn test_fourcc() { @@ -31,6 +54,27 @@ pub async fn test_fourcc() { // veilid_api/types/safety.rs +pub async fn test_sequencing() { + let orig = Sequencing::PreferOrdered; + let copy = deserialize_json(&serialize_json(&orig)).unwrap(); + + assert_eq!(orig, copy); +} + +pub async fn test_stability() { + let orig = Stability::Reliable; + let copy = deserialize_json(&serialize_json(&orig)).unwrap(); + + assert_eq!(orig, copy); +} + +pub async fn test_safetyselection() { + let orig = SafetySelection::Unsafe(Sequencing::EnsureOrdered); + let copy = deserialize_json(&serialize_json(&orig)).unwrap(); + + assert_eq!(orig, copy); +} + pub async fn test_safetyspec() { let orig = SafetySpec { preferred_route: Some(fix_cryptokey()), @@ -137,7 +181,7 @@ pub async fn test_partialtunnel() { assert_eq!(orig, copy); } -// veilid_api/types/veilid_lo.rs +// veilid_api/types/veilid_log.rs pub async fn test_veilidloglevel() { let orig = VeilidLogLevel::Info; @@ -254,7 +298,12 @@ pub async fn test_veilidstate() { pub async fn test_all() { test_round_trip_peerinfo().await; test_alignedu64().await; + test_veilidappmessage().await; + test_veilidappcall().await; test_fourcc().await; + test_sequencing().await; + test_stability().await; + test_safetyselection().await; test_safetyspec().await; test_latencystats().await; test_transferstats().await; @@ -262,7 +311,6 @@ pub async fn test_all() { test_rpcstats().await; test_peerstats().await; test_tunnelmode().await; - test_tunnelmode().await; test_tunnelerror().await; test_tunnelendpoint().await; test_fulltunnel().await; diff --git a/veilid-core/src/veilid_api/types/app_message_call.rs b/veilid-core/src/veilid_api/types/app_message_call.rs index 6f0805fe..f2485d46 100644 --- a/veilid-core/src/veilid_api/types/app_message_call.rs +++ b/veilid-core/src/veilid_api/types/app_message_call.rs @@ -8,10 +8,10 @@ use super::*; pub struct VeilidAppMessage { /// Some(sender) if the message was sent directly, None if received via a private/safety route #[serde(with = "opt_json_as_string")] - sender: Option, + pub sender: Option, /// The content of the message to deliver to the application #[serde(with = "json_as_base64")] - message: Vec, + pub message: Vec, } impl VeilidAppMessage { @@ -35,13 +35,13 @@ impl VeilidAppMessage { pub struct VeilidAppCall { /// Some(sender) if the request was sent directly, None if received via a private/safety route #[serde(with = "opt_json_as_string")] - sender: Option, + pub sender: Option, /// The content of the request to deliver to the application #[serde(with = "json_as_base64")] - message: Vec, + pub message: Vec, /// The id to reply to #[serde(with = "json_as_string")] - id: OperationId, + pub id: OperationId, } impl VeilidAppCall {