From 6457b8eef28c9fe3c4d58dd10065720a99279624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Strug?= Date: Mon, 13 May 2024 11:57:52 +0200 Subject: [PATCH] Changed compiler profile names --- radix-engine-tests/src/common.rs | 8 ++- scrypto-test/src/ledger_simulator/compile.rs | 58 ++++++++++++++++++-- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/radix-engine-tests/src/common.rs b/radix-engine-tests/src/common.rs index cdfda3ec57..8b47cdee19 100644 --- a/radix-engine-tests/src/common.rs +++ b/radix-engine-tests/src/common.rs @@ -30,6 +30,10 @@ pub mod package_loader { panic!("Package \"{}\" not found. Are you sure that this package is: a) in the blueprints folder, b) that this is the same as the package name in the Cargo.toml file?", name) } } + + pub fn get_using_standard_compiler_profile(name: &str) -> (Vec, PackageDefinition) { + panic!("Package \"{}\" already compiled. Cannot use specific compiler profile in compile-blueprints-at-build-time mode.", name) + } } } @@ -47,8 +51,8 @@ pub mod package_loader { Self::get_internal(name, CompileProfile::FastWithTraceLogs) } - pub fn get_using_default_compiler_options(name: &str) -> (Vec, PackageDefinition) { - Self::get_internal(name, CompileProfile::Default) + pub fn get_using_standard_compiler_profile(name: &str) -> (Vec, PackageDefinition) { + Self::get_internal(name, CompileProfile::Standard) } fn get_internal( diff --git a/scrypto-test/src/ledger_simulator/compile.rs b/scrypto-test/src/ledger_simulator/compile.rs index 031161c8ba..aefad239b7 100644 --- a/scrypto-test/src/ledger_simulator/compile.rs +++ b/scrypto-test/src/ledger_simulator/compile.rs @@ -5,7 +5,9 @@ use std::path::Path; pub enum CompileProfile { /// Uses default compilation options - same as `scrypto build`. Should be used in all cases which requires /// compilation results to be as close to production as possible (for instance costing related tests). - Default, + Standard, + /// Same as Standard with enabled all logs from error to trace level. + StandardWithTraceLogs, /// Disables WASM optimization to speed-up compilation process, by default used by SDK PackageFactory. Fast, /// Disables WASM optimization and enables all logs from error to trace level, by default used by Ledger Simulator. @@ -42,7 +44,10 @@ impl Compile { compiler_builder.manifest_path(package_dir.as_ref()); match compile_profile { - CompileProfile::Default => (), + CompileProfile::Standard => (), + CompileProfile::StandardWithTraceLogs => { + compiler_builder.log_level(Level::Trace); // all logs from error to trace + } CompileProfile::Fast => { compiler_builder.optimize_with_wasm_opt(None); } @@ -163,14 +168,14 @@ mod tests { } #[test] - fn validate_compile_profile_default() { + fn validate_compile_profile_standard() { // Compile blueprint using `scrypto compile` command let output_file_content = compile_blueprint(&[]); // Compile same blueprint using Compile object let (bin, _) = Compile::compile( concat!(env!("CARGO_MANIFEST_DIR"), "/tests/blueprints/tuple-return"), - CompileProfile::Default, + CompileProfile::Standard, ); // Assert @@ -185,6 +190,24 @@ mod tests { ) } + #[test] + fn validate_compile_profile_standard_with_logs() { + // Compile blueprint using `scrypto compile` command + let output_file_content = compile_blueprint(&[]); + + // Compile same blueprint using Compile object + let (bin, _) = Compile::compile( + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/blueprints/tuple-return"), + CompileProfile::StandardWithTraceLogs, + ); + + // Assert + assert!( + output_file_content.len() < bin.len(), + "Size of Wasm file compiled by `scrypto build` command should be smaller." + ); + } + #[test] fn validate_compile_profile_fast() { // Compile blueprint using `scrypto compile` command @@ -204,7 +227,7 @@ mod tests { } #[test] - fn validate_compile_profile_fast_with_log() { + fn validate_compile_profile_fast_with_logs() { // Compile blueprint using `scrypto compile` command let output_file_content = compile_blueprint(&[]); @@ -221,6 +244,29 @@ mod tests { ); } + #[test] + fn verify_scrypto_build_with_args_for_compile_profile_standard_with_logs() { + // Compile blueprint using `scrypto compile` command + let output_file_content = compile_blueprint(&["--log-level", "TRACE"]); + + // Compile same blueprint using Compile object + let (bin, _) = Compile::compile( + concat!(env!("CARGO_MANIFEST_DIR"), "/tests/blueprints/tuple-return"), + CompileProfile::StandardWithTraceLogs, + ); + + // Assert + assert_eq!( + output_file_content.len(), + bin.len(), + "Wasm files should have same size." + ); + assert_eq!( + output_file_content, bin, + "Wasm files should have same content." + ) + } + #[test] fn verify_scrypto_build_with_args_for_compile_profile_fast() { // Compile blueprint using `scrypto compile` command @@ -245,7 +291,7 @@ mod tests { } #[test] - fn verify_scrypto_build_with_args_for_compile_profile_fast_with_log() { + fn verify_scrypto_build_with_args_for_compile_profile_fast_with_logs() { // Compile blueprint using `scrypto compile` command let output_file_content = compile_blueprint(&["--disable-wasm-opt", "--log-level", "TRACE"]);