1- use std:: collections:: HashSet ;
2-
31use blake2s:: encode_felts_to_u32s;
4- use cairo_vm:: hint_processor:: builtin_hint_processor:: hint_code:: HINT_CODES ;
5- use cairo_vm:: hint_processor:: builtin_hint_processor:: kzg_da:: WRITE_DIVMOD_SEGMENT ;
6- use cairo_vm:: hint_processor:: builtin_hint_processor:: secp:: cairo0_hints:: CAIRO0_HINT_CODES ;
7- use starknet_os:: hints:: enum_definition:: { AggregatorHint , HintExtension , OsHint } ;
8- use starknet_os:: hints:: types:: HintEnum ;
92use starknet_types_core:: felt:: Felt ;
10- use strum:: IntoEnumIterator ;
113
124use crate :: os_cli:: commands:: { validate_input, Input } ;
135use crate :: os_cli:: tests:: aliases:: aliases_test;
@@ -19,7 +11,6 @@ use crate::shared_utils::types::{PythonTestError, PythonTestRunner};
1911pub enum OsPythonTestRunner {
2012 AliasesTest ,
2113 BlsFieldTest ,
22- CompareOsHints ,
2314 InputDeserialization ,
2415 EncodeFelts ,
2516}
@@ -32,7 +23,6 @@ impl TryFrom<String> for OsPythonTestRunner {
3223 match value. as_str ( ) {
3324 "aliases_test" => Ok ( Self :: AliasesTest ) ,
3425 "bls_field_test" => Ok ( Self :: BlsFieldTest ) ,
35- "compare_os_hints" => Ok ( Self :: CompareOsHints ) ,
3626 "input_deserialization" => Ok ( Self :: InputDeserialization ) ,
3727 "encode_felts" => Ok ( Self :: EncodeFelts ) ,
3828 _ => Err ( PythonTestError :: UnknownTestName ( value) ) ,
@@ -47,7 +37,6 @@ impl PythonTestRunner for OsPythonTestRunner {
4737 match self {
4838 Self :: AliasesTest => aliases_test ( Self :: non_optional_input ( input) ?) ,
4939 Self :: BlsFieldTest => test_bls_field ( Self :: non_optional_input ( input) ?) ,
50- Self :: CompareOsHints => compare_os_hints ( Self :: non_optional_input ( input) ?) ,
5140 Self :: InputDeserialization => input_deserialization ( Self :: non_optional_input ( input) ?) ,
5241 Self :: EncodeFelts => {
5342 let felts: Vec < Felt > = serde_json:: from_str ( Self :: non_optional_input ( input) ?) ?;
@@ -57,44 +46,10 @@ impl PythonTestRunner for OsPythonTestRunner {
5746 }
5847}
5948
60- #[ allow( clippy:: result_large_err) ]
61- fn compare_os_hints ( input : & str ) -> OsPythonTestResult {
62- let unfiltered_python_hints: HashSet < String > = serde_json:: from_str ( input) ?;
63-
64- // Remove VM hints.
65- let vm_hints = vm_hints ( ) ;
66- let python_os_hints: HashSet < String > = unfiltered_python_hints
67- . into_iter ( )
68- . filter ( |hint| !vm_hints. contains ( hint. as_str ( ) ) )
69- . collect ( ) ;
70-
71- // We ignore `SyscallHint`s here, as they are not part of the compiled OS.
72- let rust_os_hints: HashSet < String > = OsHint :: iter ( )
73- . map ( |hint| hint. to_str ( ) . to_string ( ) )
74- . chain ( HintExtension :: iter ( ) . map ( |hint| hint. to_str ( ) . to_string ( ) ) )
75- . chain ( AggregatorHint :: iter ( ) . map ( |hint| hint. to_str ( ) . to_string ( ) ) )
76- . collect ( ) ;
77-
78- let mut only_in_python: Vec < String > =
79- python_os_hints. difference ( & rust_os_hints) . cloned ( ) . collect ( ) ;
80- only_in_python. sort ( ) ;
81- let mut only_in_rust: Vec < String > =
82- rust_os_hints. difference ( & python_os_hints) . cloned ( ) . collect ( ) ;
83- only_in_rust. sort ( ) ;
84- Ok ( serde_json:: to_string ( & ( only_in_python, only_in_rust) ) ?)
85- }
86-
8749/// Deserialize the input string into an `Input` struct.
8850#[ allow( clippy:: result_large_err) ]
8951fn input_deserialization ( input_str : & str ) -> OsPythonTestResult {
9052 let input = serde_json:: from_str :: < Input > ( input_str) ?;
9153 validate_input ( & input. os_hints . os_input ) ;
9254 Ok ( "Deserialization successful" . to_string ( ) )
9355}
94-
95- fn vm_hints ( ) -> HashSet < & ' static str > {
96- let mut vm_hints = HashSet :: from ( [ WRITE_DIVMOD_SEGMENT ] ) ;
97- vm_hints. extend ( HINT_CODES . values ( ) ) ;
98- vm_hints. extend ( CAIRO0_HINT_CODES . values ( ) ) ;
99- vm_hints
100- }
0 commit comments