-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(blockifier): make the utility felt_to_u128 private
- Loading branch information
1 parent
55a9d57
commit f6891af
Showing
4 changed files
with
30 additions
and
24 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
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,21 @@ | ||
use num_bigint::BigUint; | ||
use starknet_types_core::felt::Felt; | ||
|
||
use crate::abi::sierra_types::felt_to_u128; | ||
|
||
#[test] | ||
fn test_value_too_large_for_type() { | ||
// Happy flow. | ||
let n = 1991_u128; | ||
let n_as_felt = Felt::from(n); | ||
felt_to_u128(&n_as_felt).unwrap(); | ||
|
||
// Value too large for type. | ||
let overflowed_u128: BigUint = BigUint::from(1_u8) << 128; | ||
let overflowed_u128_as_felt = Felt::from(overflowed_u128); | ||
let error = felt_to_u128(&overflowed_u128_as_felt).unwrap_err(); | ||
assert_eq!( | ||
format!("{error}"), | ||
"Felt 340282366920938463463374607431768211456 is too big to convert to 'u128'." | ||
); | ||
} |
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