File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
crates/apollo_starknet_os_program/src Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ use std:: path:: PathBuf ;
2+
13use apollo_infra_utils:: cairo0_compiler:: { cairo0_format, verify_cairo0_compiler_deps} ;
4+ use apollo_infra_utils:: compile_time_cargo_manifest_dir;
25use blockifier:: blockifier_versioned_constants:: { OsConstants , VersionedConstants } ;
36use blockifier:: execution:: syscalls:: SyscallSelector ;
47use starknet_api:: core:: { ClassHash , ContractAddress , EntryPointSelector } ;
@@ -205,8 +208,22 @@ fn generate_constants_file() -> String {
205208 cairo0_format ( & unformatted)
206209}
207210
211+ /// Test that the generated constants file matches the expected contents.
212+ /// To fix this test, run:
213+ /// ```bash
214+ /// FIX_OS_CONSTANTS=1 cargo test -p apollo_starknet_os_program test_os_constants
215+ /// ```
208216#[ test]
209217fn test_os_constants ( ) {
210218 verify_cairo0_compiler_deps ( ) ;
211- assert_eq ! ( CONSTANTS_CONTENTS , generate_constants_file( ) ) ;
219+ let generated = generate_constants_file ( ) ;
220+ let fix = std:: env:: var ( "FIX_OS_CONSTANTS" ) . is_ok ( ) ;
221+ if fix {
222+ // Write the generated contents to the file.
223+ let path = PathBuf :: from ( compile_time_cargo_manifest_dir ! ( ) )
224+ . join ( "src/cairo/starkware/starknet/core/os/constants.cairo" ) ;
225+ std:: fs:: write ( path, & generated) . expect ( "Failed to write generated constants file." ) ;
226+ } else {
227+ assert_eq ! ( CONSTANTS_CONTENTS , generated) ;
228+ }
212229}
You can’t perform that action at this time.
0 commit comments