From 0cbc1e49decaef0f577c7dea735d7acd95160d15 Mon Sep 17 00:00:00 2001 From: broody Date: Thu, 21 Mar 2024 09:42:13 -1000 Subject: [PATCH] fix tests --- Cargo.toml | 1 - crates/account_sdk/Cargo.toml | 1 - crates/account_sdk/src/lib.rs | 1 + crates/account_sdk/src/tests/webauthn/mod.rs | 14 +++++++++++++- .../src/webauthn_signer/signers/p256r1.rs | 8 -------- crates/webauthn/tests/src/auth/verify_ecdsa.rs | 2 +- crates/webauthn/tests/src/auth/verify_signature.rs | 2 +- 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9514d314..ca0112ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ cainome = { git = "https://github.com/piniom/cainome", tag="v0.2.4-expand", feat "abigen-rs", "expand-expr" ] } cairo-lang-starknet = "2.4.0" -coset = { version = "0.3.4", features = ["std"] } futures = "0.3" lazy_static = "1" p256 = "0.13" diff --git a/crates/account_sdk/Cargo.toml b/crates/account_sdk/Cargo.toml index 8e51d5f1..618f9afe 100644 --- a/crates/account_sdk/Cargo.toml +++ b/crates/account_sdk/Cargo.toml @@ -14,7 +14,6 @@ async-trait.workspace = true base64.workspace = true cainome.workspace = true cairo-lang-starknet.workspace = true -coset.workspace = true futures.workspace = true lazy_static.workspace = true p256.workspace = true diff --git a/crates/account_sdk/src/lib.rs b/crates/account_sdk/src/lib.rs index eadba48a..60778475 100644 --- a/crates/account_sdk/src/lib.rs +++ b/crates/account_sdk/src/lib.rs @@ -11,4 +11,5 @@ pub mod session_token; pub mod tests; #[cfg(target_arch = "wasm32")] +#[cfg(test)] pub mod wasm_tests; diff --git a/crates/account_sdk/src/tests/webauthn/mod.rs b/crates/account_sdk/src/tests/webauthn/mod.rs index 84d8e0ff..6300fe72 100644 --- a/crates/account_sdk/src/tests/webauthn/mod.rs +++ b/crates/account_sdk/src/tests/webauthn/mod.rs @@ -65,7 +65,11 @@ async fn test_verify_webauthn_explicit() { let challenge = felt!("0x0169af1f6f99d35e0b80e0140235ec4a2041048868071a8654576223934726f5"); let challenge_bytes = challenge.to_bytes_be().to_vec(); - let response = data.signer.sign(&challenge_bytes).await; + let response = data + .signer + .sign(&challenge_bytes) + .await + .expect("signer error"); let args = VerifyWebauthnSignerArgs::from_response(origin, challenge_bytes, response.clone()); @@ -112,3 +116,11 @@ async fn test_verify_webauthn_execute() { .await; result.unwrap(); } + +#[tokio::test] +async fn test_signer() { + let rp_id = "https://localhost:8080".to_string(); + let signer = P256r1Signer::random(rp_id); + let calldata = signer.sign("842903840923".as_bytes()).await.unwrap(); + dbg!(&calldata); +} diff --git a/crates/account_sdk/src/webauthn_signer/signers/p256r1.rs b/crates/account_sdk/src/webauthn_signer/signers/p256r1.rs index d8573bb0..06a0d402 100644 --- a/crates/account_sdk/src/webauthn_signer/signers/p256r1.rs +++ b/crates/account_sdk/src/webauthn_signer/signers/p256r1.rs @@ -82,11 +82,3 @@ impl P256VerifyingKeyConverter { ) } } - -// #[tokio::test] -// async fn test_signer() { -// let rp_id = "https://localhost:8080".to_string(); -// let signer = P256r1Signer::random(rp_id); -// let calldata = signer.sign("842903840923".as_bytes()).await; -// dbg!(&calldata); -// } diff --git a/crates/webauthn/tests/src/auth/verify_ecdsa.rs b/crates/webauthn/tests/src/auth/verify_ecdsa.rs index 8301ad0c..9165c3b2 100644 --- a/crates/webauthn/tests/src/auth/verify_ecdsa.rs +++ b/crates/webauthn/tests/src/auth/verify_ecdsa.rs @@ -1,4 +1,4 @@ -use account_sdk::webauthn_signer::P256VerifyingKeyConverter; +use account_sdk::webauthn_signer::signers::p256r1::P256VerifyingKeyConverter; use p256::{ ecdsa::{signature::Signer, Signature, SigningKey}, elliptic_curve::{rand_core::OsRng, SecretKey}, diff --git a/crates/webauthn/tests/src/auth/verify_signature.rs b/crates/webauthn/tests/src/auth/verify_signature.rs index 2645a81c..551d89cc 100644 --- a/crates/webauthn/tests/src/auth/verify_signature.rs +++ b/crates/webauthn/tests/src/auth/verify_signature.rs @@ -1,4 +1,4 @@ -use account_sdk::webauthn_signer::P256VerifyingKeyConverter; +use account_sdk::webauthn_signer::signers::p256r1::P256VerifyingKeyConverter; use p256::{ ecdsa::{signature::Signer, Signature, SigningKey}, elliptic_curve::rand_core::OsRng,