-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: blockifier regression test compile class
- Loading branch information
1 parent
b65faeb
commit f0541a6
Showing
5 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 +1,3 @@ | ||
pub mod test_state_reader; | ||
pub mod test_utils; | ||
pub mod utils; |
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,43 @@ | ||
use std::collections::HashMap; | ||
use std::io::{self, Read}; | ||
|
||
use flate2::bufread; | ||
use starknet_api::core::EntryPointSelector; | ||
use starknet_api::deprecated_contract_class::{EntryPoint, EntryPointOffset, EntryPointType}; | ||
use starknet_api::hash::StarkHash; | ||
use starknet_core::types::{LegacyContractEntryPoint, LegacyEntryPointsByType}; | ||
|
||
pub fn map_entry_points_by_type_legacy( | ||
entry_points_by_type: LegacyEntryPointsByType, | ||
) -> HashMap<EntryPointType, Vec<EntryPoint>> { | ||
let entry_types_to_points = HashMap::from([ | ||
(EntryPointType::Constructor, entry_points_by_type.constructor), | ||
(EntryPointType::External, entry_points_by_type.external), | ||
(EntryPointType::L1Handler, entry_points_by_type.l1_handler), | ||
]); | ||
|
||
let to_contract_entry_point = |entrypoint: &LegacyContractEntryPoint| -> EntryPoint { | ||
let felt: StarkHash = StarkHash::from_bytes_be(&entrypoint.selector.to_bytes_be()); | ||
EntryPoint { | ||
offset: EntryPointOffset(usize::try_from(entrypoint.offset).unwrap()), | ||
selector: EntryPointSelector(felt), | ||
} | ||
}; | ||
|
||
let mut entry_points_by_type_map = HashMap::new(); | ||
for (entry_point_type, entry_points) in entry_types_to_points.into_iter() { | ||
let values = entry_points.iter().map(to_contract_entry_point).collect::<Vec<_>>(); | ||
entry_points_by_type_map.insert(entry_point_type, values); | ||
} | ||
|
||
entry_points_by_type_map | ||
} | ||
|
||
/// Uncompresses a Gz Encoded vector of bytes and returns a string or error | ||
/// Here &[u8] implements BufRead | ||
pub fn decode_reader(bytes: Vec<u8>) -> io::Result<String> { | ||
let mut gz = bufread::GzDecoder::new(&bytes[..]); | ||
let mut s = String::new(); | ||
gz.read_to_string(&mut s)?; | ||
Ok(s) | ||
} |