bug fixes

This commit is contained in:
Jazz Turner-Baggs 2026-06-22 16:46:35 -07:00
parent a52db1c8ca
commit ac4cab64ef
No known key found for this signature in database
4 changed files with 27 additions and 35 deletions

View File

@ -191,18 +191,22 @@ fn run_logos_delivery(cli: Cli) -> Result<()> {
.to_str()
.context("db path contains non-UTF-8 characters")?
.to_string();
logos_chat::ChatClient::open(
cli.name.clone(),
logos_chat::StorageConfig::Encrypted {
logos_chat::ChatClientBuilder::new()
.storage_config(logos_chat::StorageConfig::Encrypted {
path: db_str,
key: "chat-cli".to_string(),
},
delivery,
)
.map_err(|e| anyhow::anyhow!("{e:?}"))
.context("failed to open persistent client")?
})
.transport(delivery)
.build()
.map_err(|e| anyhow::anyhow!("{e:?}"))
.context("failed to open persistent client")?
}
None => logos_chat::ChatClient::new(cli.name.clone(), delivery),
None => logos_chat::ChatClientBuilder::new()
.transport(delivery)
.build()
.map_err(|e| anyhow::anyhow!("{e:?}"))
.context("failed to open chat client")?,
};
let mut app = ChatApp::new(client, events, &cli.name, &data_dir)?;

View File

@ -26,6 +26,8 @@ use crate::{
types::AddressedEncryptedPayload,
};
const OUTBOUND_HASH_CACHE_SIZE: usize = 25;
pub struct GroupV1Convo {
mls_group: MlsGroup,
convo_id: String,
@ -196,6 +198,9 @@ impl GroupV1Convo {
// Hash and Cache to detect inbound messages
let msg_hash = blake2b_hex::<hash_size::MessageId>(&[&msg_bytes]);
self.outbound_msgs.push_back(msg_hash);
if self.outbound_msgs.len() > OUTBOUND_HASH_CACHE_SIZE {
let _ = self.outbound_msgs.remove(0);
}
// Wrap in Payload frames
let aep = AddressedEncryptedPayload {
@ -211,7 +216,7 @@ impl GroupV1Convo {
// Send via DS
cx.ds
.publish(env)
.map_err(|e| ChatError::Generic(format!("Publish: {e}")))
.map_err(|e| ChatError::Delivery(e.to_string()))
}
}

View File

@ -30,7 +30,10 @@ fn main() {
if let Event::MessageReceived { content, .. } =
raya_events.recv_timeout(Duration::from_secs(5)).unwrap()
{
println!("Raya received: {:?}", std::str::from_utf8(&content).unwrap());
println!(
"Raya received: {:?}",
std::str::from_utf8(&content).unwrap()
);
}
raya.send_message(&raya_convo_id, b"hi saro").unwrap();
@ -38,7 +41,10 @@ fn main() {
if let Event::MessageReceived { content, .. } =
saro_events.recv_timeout(Duration::from_secs(5)).unwrap()
{
println!("Saro received: {:?}", std::str::from_utf8(&content).unwrap());
println!(
"Saro received: {:?}",
std::str::from_utf8(&content).unwrap()
);
}
println!("Message exchange complete.");

View File

@ -261,29 +261,6 @@ fn dropping_client_shuts_down_worker() {
));
}
#[test]
fn publish_failure_surfaces_as_error() {
// A real raya just to mint a valid intro bundle.
let (mut saro, _events) =
create_test_client(MessageBus::default(), EphemeralRegistry::new()).expect("client create");
// FailingDelivery never receives; keep the inbound sender alive so the
// worker doesn't exit early on a disconnected channel.
let delivery = FailingDelivery::new();
let _keep_inbound = delivery.inbound_sender();
let (raya, _raya_events) = ChatClientBuilder::new()
.transport(delivery)
.build()
.expect("create client");
let result = saro.create_direct_conversation(raya.addr());
assert!(
result.is_err(),
"publish failure should surface as an error on the synchronous call"
);
}
#[test]
fn malformed_inbound_surfaces_as_error_event() {
// Feed the worker's inbound channel bytes that can't be decoded and assert