fix(crypto): fix incorrect VerificationMachine tests

- the tests used to incorrectly wrap the to-device content into an event as if it was sent by alice instead of bob
This commit is contained in:
Stefan Ceriu
2024-10-15 17:13:27 +03:00
committed by Stefan Ceriu
parent bb8b0cf6b9
commit 8469cb1146
3 changed files with 11 additions and 10 deletions

View File

@@ -341,6 +341,7 @@ impl VerificationMachine {
match &content {
AnyVerificationContent::Request(r) => {
info!(
sender = ?event.sender(),
from_device = r.from_device().as_str(),
"Received a new verification request",
);
@@ -733,12 +734,12 @@ mod tests {
let content: OutgoingContent = request.try_into().unwrap();
machine
.receive_any_event(&wrap_any_to_device_content(bob_request.other_user(), content))
.receive_any_event(&wrap_any_to_device_content(bob_request.own_user_id(), content))
.await
.unwrap();
let alice_request =
machine.get_request(bob_request.other_user(), bob_request.flow_id().as_str()).unwrap();
machine.get_request(bob_request.own_user_id(), bob_request.flow_id().as_str()).unwrap();
// We're not yet cancelled.
assert!(!alice_request.is_cancelled());
@@ -757,12 +758,12 @@ mod tests {
let content: OutgoingContent = request.try_into().unwrap();
machine
.receive_any_event(&wrap_any_to_device_content(bob_request.other_user(), content))
.receive_any_event(&wrap_any_to_device_content(bob_request.own_user_id(), content))
.await
.unwrap();
let second_request =
machine.get_request(bob_request.other_user(), bob_request.flow_id().as_str()).unwrap();
machine.get_request(bob_request.own_user_id(), bob_request.flow_id().as_str()).unwrap();
// Make sure we fetched the new one.
assert_eq!(second_request.flow_id().as_str(), second_transaction_id);
@@ -795,12 +796,12 @@ mod tests {
let content: OutgoingContent = request.try_into().unwrap();
machine
.receive_any_event(&wrap_any_to_device_content(bob_request.other_user(), content))
.receive_any_event(&wrap_any_to_device_content(bob_request.own_user_id(), content))
.await
.unwrap();
let first_request =
machine.get_request(bob_request.other_user(), bob_request.flow_id().as_str()).unwrap();
machine.get_request(bob_request.own_user_id(), bob_request.flow_id().as_str()).unwrap();
// We're not yet cancelled.
assert!(!first_request.is_cancelled());
@@ -819,12 +820,12 @@ mod tests {
let content: OutgoingContent = request.try_into().unwrap();
machine
.receive_any_event(&wrap_any_to_device_content(bob_request.other_user(), content))
.receive_any_event(&wrap_any_to_device_content(bob_request.own_user_id(), content))
.await
.unwrap();
let second_request =
machine.get_request(bob_request.other_user(), bob_request.flow_id().as_str()).unwrap();
machine.get_request(bob_request.own_user_id(), bob_request.flow_id().as_str()).unwrap();
// None of the requests are cancelled
assert!(!first_request.is_cancelled());

View File

@@ -819,7 +819,7 @@ pub(crate) mod tests {
}
pub fn bob_device_id() -> &'static DeviceId {
device_id!("BOBDEVCIE")
device_id!("BOBDEVICE")
}
pub(crate) async fn setup_stores() -> (Account, VerificationStore, Account, VerificationStore) {

View File

@@ -899,7 +899,7 @@ mod tests {
}
fn bob_device_id() -> &'static DeviceId {
device_id!("BOBDEVCIE")
device_id!("BOBDEVICE")
}
fn machine_pair_test_helper() -> (VerificationStore, DeviceData, VerificationStore, DeviceData)