-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(committer): use FilledTree::create() in filled forest (#495)
- Loading branch information
1 parent
091490f
commit 7f4e7b3
Showing
5 changed files
with
138 additions
and
60 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
25 changes: 25 additions & 0 deletions
25
crates/starknet_committer/src/block_committer/input_test.rs
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,25 @@ | ||
use rstest::rstest; | ||
use starknet_patricia::felt::Felt; | ||
use starknet_patricia::patricia_merkle_tree::types::NodeIndex; | ||
|
||
use crate::block_committer::input::ContractAddress; | ||
|
||
#[rstest] | ||
fn test_node_index_to_contract_address_conversion() { | ||
// Positive flow. | ||
assert_eq!(ContractAddress::try_from(&NodeIndex::FIRST_LEAF), Ok(ContractAddress(Felt::ZERO))); | ||
assert_eq!( | ||
ContractAddress::try_from(&(NodeIndex::FIRST_LEAF + NodeIndex(1_u32.into()))), | ||
Ok(ContractAddress(Felt::ONE)) | ||
); | ||
assert_eq!( | ||
ContractAddress::try_from(&NodeIndex::MAX), | ||
Ok(ContractAddress(Felt::try_from(NodeIndex::MAX - NodeIndex::FIRST_LEAF).unwrap())) | ||
); | ||
|
||
// Negative flow. | ||
assert_eq!( | ||
ContractAddress::try_from(&(NodeIndex::FIRST_LEAF - NodeIndex(1_u32.into()))), | ||
Err("NodeIndex is not a leaf.".to_string()) | ||
); | ||
} |
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