Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 12 additions & 29 deletions crates/forge/tests/integration/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ use crate::utils::running_tests::run_test_case;
use crate::utils::test_case;
use forge_runner::forge_config::ForgeTrackedResource;
use indoc::{formatdoc, indoc};
use scarb_api::version::scarb_version;
use semver::Version;
use shared::test_utils::node_url::node_rpc_url;
use starknet_api::execution_resources::{GasAmount, GasVector};
use std::path::Path;
Expand Down Expand Up @@ -271,33 +269,18 @@ fn contract_range_check_cost_cairo_steps() {

assert_passed(&result);

let scarb_version = scarb_version().expect("Failed to get scarb version").scarb;

// TODO(#4087): Remove this when bumping minimal recommended Scarb version to 2.14.0
if scarb_version >= Version::new(2, 14, 0) {
// 96 = cost of deploy (see snforge_std_deploy_cost test)
// 43 = cost of 1052 range check builtins (because int(0.04 * 1052) = 43)
// 0 l1_gas + 96 l1_data_gas + 43 * (100 / 0.0025) l2 gas
assert_gas(
&result,
"contract_range_check_cost",
GasVector {
l1_gas: GasAmount(0),
l1_data_gas: GasAmount(96),
l2_gas: GasAmount(1_720_000),
},
);
} else {
assert_gas(
&result,
"contract_range_check_cost",
GasVector {
l1_gas: GasAmount(0),
l1_data_gas: GasAmount(96),
l2_gas: GasAmount(6_520_000),
},
);
}
// 96 = cost of deploy (see snforge_std_deploy_cost test)
// 43 = cost of 1052 range check builtins (because int(0.04 * 1052) = 43)
// 0 l1_gas + 96 l1_data_gas + 43 * (100 / 0.0025) l2 gas
assert_gas(
&result,
"contract_range_check_cost",
GasVector {
l1_gas: GasAmount(0),
l1_data_gas: GasAmount(96),
l2_gas: GasAmount(1_720_000),
},
);
}

#[test]
Expand Down
63 changes: 20 additions & 43 deletions crates/sncast/tests/e2e/script/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ use crate::helpers::runner::runner;
use camino::Utf8PathBuf;
use indoc::{formatdoc, indoc};
use scarb_api::ScarbCommand;
use scarb_api::version::scarb_version;
use semver::Version;
use shared::test_utils::output_assert::{assert_stderr_contains, assert_stdout_contains};
use sncast::helpers::constants::INIT_SCRIPTS_DIR;
use sncast::helpers::scarb_utils::get_cairo_version;
use tempfile::TempDir;

const SCARB_2_14_0: Version = Version::new(2, 14, 0);

#[test]
fn test_script_init_happy_case() {
let script_name = "my_script";
Expand Down Expand Up @@ -38,45 +34,26 @@ fn test_script_init_happy_case() {
let scarb_toml_path = Utf8PathBuf::from_path_buf(scarb_toml_path).unwrap();
let cairo_version = get_cairo_version(&scarb_toml_path).unwrap();

let scarb_version = scarb_version().unwrap().scarb;

let expected_scarb_toml = if scarb_version >= SCARB_2_14_0 {
formatdoc!(
r#"
[package]
name = "{script_name}"
version = "0.1.0"
edition = [..]

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[executable]

[cairo]
enable-gas = false

[dependencies]
cairo_execute = "{cairo_version}"
sncast_std = "{cast_version}"
starknet = ">={cairo_version}"
"#
)
} else {
formatdoc!(
r#"
[package]
name = "{script_name}"
version = "0.1.0"
edition = [..]

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[dependencies]
sncast_std = "{cast_version}"
starknet = ">={cairo_version}"
"#
)
};
let expected_scarb_toml = formatdoc!(
r#"
[package]
name = "{script_name}"
version = "0.1.0"
edition = [..]

# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html

[executable]

[cairo]
enable-gas = false

[dependencies]
cairo_execute = "{cairo_version}"
sncast_std = "{cast_version}"
starknet = ">={cairo_version}"
"#
);

snapbox::assert_data_eq!(scarb_toml_content, expected_scarb_toml);

Expand Down
Loading