2025-12-22 09:40:46 -08:00
|
|
|
mod api;
|
|
|
|
|
mod context;
|
|
|
|
|
mod conversation;
|
2026-01-22 06:39:09 +07:00
|
|
|
mod crypto;
|
2025-12-22 09:40:46 -08:00
|
|
|
mod errors;
|
2026-01-22 06:39:09 +07:00
|
|
|
mod identity;
|
2025-12-22 09:40:46 -08:00
|
|
|
mod inbox;
|
2026-01-22 06:39:09 +07:00
|
|
|
mod proto;
|
|
|
|
|
mod types;
|
|
|
|
|
mod utils;
|
2025-12-22 09:40:46 -08:00
|
|
|
|
|
|
|
|
pub use api::*;
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_ffi() {}
|
|
|
|
|
|
2026-01-29 01:50:41 +07:00
|
|
|
#[test]
|
|
|
|
|
fn test_message_roundtrip() {
|
2026-02-19 17:25:42 -08:00
|
|
|
let mut saro = create_context("saro".into());
|
|
|
|
|
let mut raya = create_context("raya".into());
|
2026-01-29 01:50:41 +07:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
// Raya Creates Bundle and Sends to Saro
|
|
|
|
|
let intro_result = create_intro_bundle(&mut raya);
|
|
|
|
|
assert!(is_ok(intro_result.error_code));
|
2025-12-22 09:40:46 -08:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
let raya_bundle = intro_result.intro_bytes.as_ref();
|
2025-12-22 09:40:46 -08:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
// Saro creates a new conversation with Raya
|
|
|
|
|
let content: &[u8] = "hello".as_bytes();
|
2025-12-22 09:40:46 -08:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
let convo_result = create_new_private_convo(&mut saro, raya_bundle, content.into());
|
|
|
|
|
assert!(is_ok(convo_result.error_code));
|
2026-01-29 01:50:41 +07:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
// Raya recieves initial message
|
|
|
|
|
let payload = convo_result.payloads.first().unwrap();
|
2026-01-29 01:50:41 +07:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
let handle_result = handle_payload(&mut raya, payload.data.as_ref());
|
|
|
|
|
assert!(is_ok(handle_result.error_code));
|
2026-01-29 01:50:41 +07:00
|
|
|
|
2026-02-09 06:37:47 -08:00
|
|
|
// Check that the Content sent was the content received
|
|
|
|
|
assert!(handle_result.content.as_ref().as_slice() == content);
|
2026-01-29 01:50:41 +07:00
|
|
|
|
|
|
|
|
destroy_context(saro);
|
|
|
|
|
destroy_context(raya);
|
2025-12-22 09:40:46 -08:00
|
|
|
}
|
|
|
|
|
}
|