File tree Expand file tree Collapse file tree
crates/apollo_starknet_os_program/src Expand file tree Collapse file tree 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 } ;
@@ -190,8 +193,22 @@ fn generate_constants_file() -> String {
190193 cairo0_format ( & unformatted)
191194}
192195
196+ /// Test that the generated constants file matches the expected contents.
197+ /// To fix this test, run:
198+ /// ```bash
199+ /// FIX_OS_CONSTANTS=1 cargo test -p apollo_starknet_os_program test_os_constants
200+ /// ```
193201#[ test]
194202fn test_os_constants ( ) {
195203 verify_cairo0_compiler_deps ( ) ;
196- assert_eq ! ( CONSTANTS_CONTENTS , generate_constants_file( ) ) ;
204+ let generated = generate_constants_file ( ) ;
205+ let fix = std:: env:: var ( "FIX_OS_CONSTANTS" ) . is_ok ( ) ;
206+ if fix {
207+ // Write the generated contents to the file.
208+ let path = PathBuf :: from ( compile_time_cargo_manifest_dir ! ( ) )
209+ . join ( "src/cairo/starkware/starknet/core/os/constants.cairo" ) ;
210+ std:: fs:: write ( path, & generated) . expect ( "Failed to write generated constants file." ) ;
211+ } else {
212+ assert_eq ! ( CONSTANTS_CONTENTS , generated) ;
213+ }
197214}
You can’t perform that action at this time.
0 commit comments