Skip to content

Commit

Permalink
need to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx committed Nov 15, 2023
1 parent 56279c0 commit e4bb3a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
42 changes: 20 additions & 22 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,41 +195,39 @@ where
}

pub(crate) async fn publish_intents(&self, conn: &mut DbConnection) -> Result<(), GroupError> {
let mut openmls_group = self.load_mls_group(&self.client.mls_provider(conn))?;
let provider = self.client.mls_provider(conn);
let mut openmls_group = self.load_mls_group(&provider)?;

let intents = EncryptedMessageStore::find_group_intents(
conn,
&mut provider.conn().borrow_mut(),
self.group_id.clone(),
Some(vec![IntentState::ToPublish]),
None,
)?;
for intent in intents {
let result = XmtpOpenMlsProvider::transaction(conn, |provider| {
let (payload, post_commit_data) =
self.get_publish_intent_data(&provider, &mut openmls_group, &intent)?;

let payload_slice = payload.as_slice();

self.client
.api_client
.publish_to_group(vec![payload_slice])
.await?;

EncryptedMessageStore::set_group_intent_published(
&mut provider.conn().borrow_mut(),
intent.id,
sha256(payload_slice),
post_commit_data,
)?;
Ok::<_, GroupError>(())
});

for intent in intents {
let result = self.get_publish_intent_data(&provider, &mut openmls_group, &intent);
if let Err(e) = result {
log::error!("error getting publish intent data {:?}", e);
// TODO: Figure out which types of errors we should abort completely on and which
// ones are safe to continue with
continue;
}

let (payload, post_commit_data) = result.expect("result already checked");
let payload_slice = payload.as_slice();

self.client
.api_client
.publish_to_group(vec![payload_slice])
.await?;

EncryptedMessageStore::set_group_intent_published(
&mut provider.conn().borrow_mut(),
intent.id,
sha256(payload_slice),
post_commit_data,
)?;
}
openmls_group.save(self.client.mls_provider(conn).key_store())?;

Expand Down
2 changes: 1 addition & 1 deletion xmtp_mls/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ mod tests {
let store = EncryptedMessageStore::new_test();
let mut conn = store.conn().unwrap();
let provider = XmtpOpenMlsProvider::new(&mut conn);
Identity::new(&provider, &generate_local_wallet()).unwrap();
Identity::new(&store, &provider, &generate_local_wallet()).unwrap();
}
}

0 comments on commit e4bb3a3

Please sign in to comment.