use closure_app::core::crypto::{decrypt, encrypt};

#[test]
fn test_encrypt_decrypt_roundtrip() {
    let password = "correct-horse-battery-staple";
    let plaintext = b"hello, closure!";

    let ciphertext = encrypt(plaintext, password).unwrap();
    let decrypted = decrypt(&ciphertext, password).unwrap();

    assert_eq!(decrypted, plaintext);
}

#[test]
fn test_decrypt_wrong_password_fails() {
    let password = "correct-horse-battery-staple";
    let wrong_password = "wrong-password";
    let plaintext = b"hello, closure!";

    let ciphertext = encrypt(plaintext, password).unwrap();
    let result = decrypt(&ciphertext, wrong_password);

    assert!(result.is_err());
}
