mirror of
https://github.com/chatmail/core.git
synced 2026-04-22 16:06:30 +03:00
test: return chat ID from TestContext.exec_securejoin_qr()
This commit is contained in:
@@ -167,7 +167,10 @@ impl TestContextManager {
|
||||
);
|
||||
}
|
||||
|
||||
pub async fn execute_securejoin(&self, scanner: &TestContext, scanned: &TestContext) {
|
||||
/// Executes SecureJoin protocol between `scanner` and `scanned`.
|
||||
///
|
||||
/// Returns chat ID of the 1:1 chat for `scanner`.
|
||||
pub async fn execute_securejoin(&self, scanner: &TestContext, scanned: &TestContext) -> ChatId {
|
||||
self.section(&format!(
|
||||
"{} scans {}'s QR code",
|
||||
scanner.name(),
|
||||
@@ -175,12 +178,20 @@ impl TestContextManager {
|
||||
));
|
||||
|
||||
let qr = get_securejoin_qr(&scanned.ctx, None).await.unwrap();
|
||||
self.exec_securejoin_qr(scanner, scanned, &qr).await;
|
||||
self.exec_securejoin_qr(scanner, scanned, &qr).await
|
||||
}
|
||||
|
||||
/// Executes SecureJoin initiated by `scanner` scanning `qr` generated by `scanned`.
|
||||
pub async fn exec_securejoin_qr(&self, scanner: &TestContext, scanned: &TestContext, qr: &str) {
|
||||
join_securejoin(&scanner.ctx, qr).await.unwrap();
|
||||
///
|
||||
/// The [`ChatId`] of the created chat is returned, for a SetupContact QR this is the 1:1
|
||||
/// chat with `scanned`, for a SecureJoin QR this is the group chat.
|
||||
pub async fn exec_securejoin_qr(
|
||||
&self,
|
||||
scanner: &TestContext,
|
||||
scanned: &TestContext,
|
||||
qr: &str,
|
||||
) -> ChatId {
|
||||
let chat_id = join_securejoin(&scanner.ctx, qr).await.unwrap();
|
||||
|
||||
loop {
|
||||
if let Some(sent) = scanner.pop_sent_msg_opt(Duration::ZERO).await {
|
||||
@@ -191,6 +202,7 @@ impl TestContextManager {
|
||||
break;
|
||||
}
|
||||
}
|
||||
chat_id
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user