use crate::integration::common::*;

#[test]
fn token_init_random_token_label() -> Result<()> {
    let sqc = SqCryptoki::new();

    let slot = sqc.allocate_slot();

    // This will only succeed if the token is initialized.
    let algo = sequoia_openpgp::crypto::PublicKeyAlgorithm::Ed25519;
    let _ = sqc.try_key_generate(slot, None, algo, true, Default::default(), "1234");

    // Initialize the token.
    sqc.token_init(slot, None, "123456", "1234");

    // This will now always succeed.
    sqc.key_generate(slot, None, algo, true, Default::default(), "1234");

    Ok(())
}
