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

Adding some tests for is_valid_signature #121

Merged
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
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
Loading