Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wildcard session message signing test #1470

Merged
merged 2 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions packages/account_sdk/src/tests/session_off_chain_sig_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub async fn test_session_off_chain_sig_via_controller() {
let owner = Owner::Signer(Signer::new_starknet_random());
let runner = KatanaRunner::load();
let mut controller = runner
.deploy_controller("username".to_owned(), owner, Version::LATEST)
.deploy_controller("username".to_owned(), owner.clone(), Version::LATEST)
.await;

let typed_data = TypedData {
Expand Down Expand Up @@ -236,7 +236,7 @@ pub async fn test_session_off_chain_sig_via_controller() {
.await
.unwrap();

let signature = controller.sign_message(typed_data).await.unwrap();
let signature = controller.sign_message(typed_data.clone()).await.unwrap();
assert_eq!(signature[0], SESSION_TYPED_DATA_MAGIC);

let contract_reader = ControllerReader::new(controller.address, runner.client());
Expand All @@ -247,4 +247,26 @@ pub async fn test_session_off_chain_sig_via_controller() {
.unwrap();

assert_ne!(is_valid, Felt::ZERO);

let mut wildcard_controller = runner
.deploy_controller("wildcard".to_owned(), owner, Version::LATEST)
.await;
let wildcard_hashes = typed_data.encode(wildcard_controller.address).unwrap();

wildcard_controller
.create_wildcard_session(u64::MAX)
.await
.unwrap();

let signature = wildcard_controller.sign_message(typed_data).await.unwrap();
assert_eq!(signature[0], SESSION_TYPED_DATA_MAGIC);

let contract_reader = ControllerReader::new(wildcard_controller.address, runner.client());
let is_valid = contract_reader
.is_valid_signature(&wildcard_hashes.hash, &signature)
.call()
.await
.unwrap();

assert_ne!(is_valid, Felt::ZERO);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.