Skip to content

Commit

Permalink
Adding some tests for is_valid_signature (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerson2102 authored Nov 4, 2024
1 parent 23bce77 commit 8ca6d6d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions snphone-contracts/.snfoundry_cache/.prev_tests_failed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tests::test_account::test_empty_signature
26 changes: 26 additions & 0 deletions snphone-contracts/tests/test_account.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,32 @@ fn test_other_account_cannot_change_public_key() {
//fn test_is_valid_signature() { // TODO: Test is_valid_signature() works as expected (valid returns true, anything else returns false (check 0 hash and empty sigs as well))
//}

#[test]
fn test_is_not_valid_signature() {
let class_hash = declare("StarknetPhoneAccount");
let _pub_key = 'pub_key';
let contract_address = class_hash.deploy(@array![_pub_key]).unwrap();
let wallet = IStarknetPhoneAccountDispatcher { contract_address };
assert(
wallet.is_valid_signature(0x0, array!['starknet', 'phone'].span()) == 0, 'Valid signature'
);
}
#[test]
fn test_empty_signature() {
let class_hash = declare("StarknetPhoneAccount");
let _pub_key = 'pub_key';
let contract_address = class_hash.deploy(@array![_pub_key]).unwrap();
let wallet = IStarknetPhoneAccountDispatcher { contract_address };
assert(
wallet.is_valid_signature('test', array![].span()) == 'invalid signature', 'Empty signature'
);
}
//#[test]
//fn test_execute() { // TODO: Test __execute__() works as expected (solo and multi-calls should work as expected)
// - Might need to create a mock erc20 contract to test calls (see if the wallet is able to do a multi call (try sending eth to 2 accounts from the
// deployed wallet, both accounts' balance should update)
//}

#[test]
#[should_panic(expected: ('invalid caller',))]
fn test_execute_with_invalid_caller() {
Expand Down

0 comments on commit 8ca6d6d

Please sign in to comment.