Skip to content

Commit

Permalink
test: Add test for info string construction.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkasak committed May 15, 2024
1 parent 56d33cf commit 8a41847
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/ecies/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,37 @@ mod test {
assert_eq!(digit, 55, "u8::MAX should generate 55");
}

#[test]
fn test_info_construction() {
use crate::types::Curve25519Keypair;

let app_info = "foobar";
let our_public_key = Curve25519Keypair::new().public_key;
let their_public_key = Curve25519Keypair::new().public_key;

let check_code_info1 = EstablishedEcies::get_check_code_info(
app_info,
Role::Initiator,
our_public_key,
their_public_key,
);
assert_eq!(
check_code_info1,
format!("foobar_CHECKCODE|{their_public_key}|{our_public_key}")
);

let check_code_info2 = EstablishedEcies::get_check_code_info(
app_info,
Role::Recipient,
our_public_key,
their_public_key,
);
assert_eq!(
check_code_info2,
format!("foobar_CHECKCODE|{our_public_key}|{their_public_key}")
);
}

proptest! {
#[test]
fn check_code_proptest(bytes in prop::array::uniform2(0u8..) ) {
Expand Down

0 comments on commit 8a41847

Please sign in to comment.