generated from keep-starknet-strange/alexandria
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod test_cairo1_helpers; | ||
mod test_contract_account; | ||
|
||
mod test_data; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use contracts::cairo1_helpers::Cairo1Helpers; | ||
use utils::helpers::BytesUsedTrait; | ||
|
||
#[test] | ||
fn test_keccak() { | ||
// "Hello world!" | ||
// where: | ||
// 8031924123371070792 == int.from_bytes(b'Hello wo', 'little') | ||
// 560229490 == int.from_bytes(b'rld!', 'little') | ||
let input = array![8031924123371070792]; | ||
let last_input_word: u64 = 560229490; | ||
let last_input_num_bytes = last_input_word.bytes_used(); | ||
let state = Cairo1Helpers::contract_state_for_testing(); | ||
|
||
let res = Cairo1Helpers::Helpers::keccak( | ||
@state, input, last_input_word, last_input_num_bytes.into() | ||
); | ||
|
||
assert_eq!(res, 0xecd0e108a98e192af1d2c25055f4e3bed784b5c877204e73219a5203251feaab); | ||
} |