Skip to content

Commit

Permalink
fixup! Add some tests for ratchet counting
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Mar 20, 2024
1 parent bbfb121 commit 5599cef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/olm/session/double_ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ mod test {
let (mut alice_session, mut bob_session) =
create_session_pair(&Account::new(), &mut Account::new());

// Both ratchets should start with count 0
// Both ratchets should start with count 0.
assert_eq!(
assert_active_ratchet(&alice_session.sending_ratchet).ratchet_count,
RatchetCount::Known(0)
Expand All @@ -385,7 +385,7 @@ mod test {
RatchetCount::Known(0)
);

// Once Bob replies, the ratchets should bump to 1
// Once Bob replies, the ratchets should bump to 1.
let olm_message = bob_session.encrypt("sssh");
alice_session.decrypt(&olm_message).expect("Alice could not decrypt message from Bob");
assert_eq!(
Expand All @@ -397,7 +397,7 @@ mod test {
RatchetCount::Known(1)
);

// Now Alice replies again
// Now Alice replies again.
let olm_message = alice_session.encrypt("sssh");
bob_session.decrypt(&olm_message).expect("Bob could not decrypt message from Alice");
assert_eq!(
Expand All @@ -415,7 +415,7 @@ mod test {
let (_, _, mut alice_session, bob_libolm_session) =
session_and_libolm_pair().expect("unable to create sessions");

// Import the libolm session into a proper vodozmac session
// Import the libolm session into a proper Vodozmac session.
let key = b"DEFAULT_PICKLE_KEY";
let pickle =
bob_libolm_session.pickle(olm_rs::PicklingMode::Encrypted { key: key.to_vec() });
Expand All @@ -427,7 +427,7 @@ mod test {
RatchetCount::Unknown(())
);

// Once Bob replies, Alice's count bumps to 1, but Bob's remains unknown
// Once Bob replies, Alice's count bumps to 1, but Bob's remains unknown.
let olm_message = bob_session.encrypt("sssh");
alice_session.decrypt(&olm_message).expect("Alice could not decrypt message from Bob");
assert_eq!(
Expand All @@ -439,7 +439,7 @@ mod test {
RatchetCount::Unknown(())
);

// Now Alice replies again
// Now Alice replies again.
let olm_message = alice_session.encrypt("sssh");
bob_session.decrypt(&olm_message).expect("Bob could not decrypt message from Alice");
assert_eq!(
Expand Down

0 comments on commit 5599cef

Please sign in to comment.