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 00a85b2 commit bbfb121
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/olm/session/double_ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,21 +339,18 @@ mod test {

fn create_session_pair(alice: &Account, bob: &mut Account) -> (Session, Session) {
let bob_otks = bob.generate_one_time_keys(1);
let bob_otk = bob_otks.created.get(0).expect("Couldn't get a one-time-key for bob");
let bob_otk = bob_otks.created.first().expect("Couldn't get a one-time-key for bob");
let bob_identity_key = bob.identity_keys().curve25519;
let mut alice_session = alice.create_outbound_session(
SessionConfig::version_1(),
bob_identity_key,
bob_otk.clone(),
);
let mut alice_session =
alice.create_outbound_session(SessionConfig::version_1(), bob_identity_key, *bob_otk);

let message = "It's a secret to everybody";
let olm_message = alice_session.encrypt(message);
let prekey_message = assert_matches!(olm_message, OlmMessage::PreKey(m) => m);

let alice_identity_key = alice.identity_keys().curve25519;
let bob_session_creation_result = bob
.create_inbound_session(alice_identity_key.clone(), &prekey_message)
.create_inbound_session(alice_identity_key, &prekey_message)
.expect("Unable to create inbound session");
assert_eq!(bob_session_creation_result.plaintext, message.as_bytes());
(alice_session, bob_session_creation_result.session)
Expand Down

0 comments on commit bbfb121

Please sign in to comment.