Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scheduled tests for Scarb 2.9.2 #2804

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- .github/workflows/scheduled.yml
schedule:
- cron: '0 0 * * 3,0'
workflow_dispatch:

jobs:
get-scarb-versions:
Expand Down
10 changes: 10 additions & 0 deletions crates/forge/test_utils/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use scarb_api::{
get_contracts_artifacts_and_source_sierra_paths, metadata::MetadataCommandExt,
target_dir_for_workspace, ScarbCommand, StarknetContractArtifacts,
};
use semver::Version;
use shared::command::CommandExt;
use std::{
collections::HashMap,
Expand Down Expand Up @@ -334,6 +335,15 @@ pub fn assert_builtin(
builtin: BuiltinName,
expected_count: usize,
) {
// TODO(#2806)
let scarb_version = ScarbCommand::version().run().unwrap();
let expected_count =
if builtin == BuiltinName::range_check && scarb_version.scarb >= Version::new(2, 9, 2) {
expected_count - 1
} else {
expected_count
};
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved

let test_name_suffix = format!("::{test_case_name}");
let result = TestCase::find_test_result(result);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use starknet::ContractAddress;

use snforge_std::{declare, ContractClassTrait, DeclareResultTrait};

use nonexistent_selector::IMyContractSafeDispatcher;
Expand Down
13 changes: 6 additions & 7 deletions crates/forge/tests/data/steps/src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// 75 constant cost
// 75/70 constant cost depending on the Cairo version
// 15 steps per iteration
#[cfg(test)]
mod tests {
#[test]
// requires 570030 steps
fn steps_570030() {
fn steps_much_less_than_10000000() {
let mut i = 0;

while i != 37_997 {
Expand All @@ -14,7 +13,7 @@ mod tests {
}

#[test]
fn steps_9999990() {
fn steps_less_than_10000000() {
let mut i = 0;

while i != 666_661 {
Expand All @@ -24,17 +23,17 @@ mod tests {
}

#[test]
fn steps_10000005() {
fn steps_more_than_10000000() {
let mut i = 0;

while i != 666_662 {
while i != 666_663 {
i = i + 1;
assert(1 + 1 == 2, 'who knows?');
}
}

#[test]
fn steps_11250075() {
fn steps_much_more_than_10000000() {
let mut i = 0;

while i != 750_000 {
Expand Down
22 changes: 9 additions & 13 deletions crates/forge/tests/e2e/running.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,42 +1032,38 @@ fn incompatible_snforge_std_version_warning() {
.unwrap()
.parse::<DocumentMut>()
.unwrap();
scarb_toml["dev-dependencies"]["snforge_std"]["path"] = Item::None;
scarb_toml["dev-dependencies"]["snforge_std"]["git"] =
value("https://github.com/foundry-rs/starknet-foundry.git");
scarb_toml["dev-dependencies"]["snforge_std"]["tag"] = value("v0.28.0");
scarb_toml["dev-dependencies"]["snforge_std"] = value("0.34.0");
manifest_path.write_str(&scarb_toml.to_string()).unwrap();

let output = test_runner(&temp).assert().failure();

assert_stdout_contains(
output,
indoc! {r"
[..]Updating git repository https://github.com/foundry-rs/starknet-foundry
[WARNING] Package snforge_std version does not meet the recommended version requirement =0.[..], [..]
[..]Compiling[..]
[..]Finished[..]


Collected 4 test(s) from steps package
Running 4 test(s) from src/
[PASS] steps::tests::steps_570030 [..]
[FAIL] steps::tests::steps_10000005
[PASS] steps::tests::steps_much_less_than_10000000 [..]
[FAIL] steps::tests::steps_more_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[FAIL] steps::tests::steps_11250075
[FAIL] steps::tests::steps_much_more_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[PASS] steps::tests::steps_9999990 [..]
[PASS] steps::tests::steps_less_than_10000000 [..]
Tests: 2 passed, 2 failed, 0 skipped, 0 ignored, 0 filtered out

Failures:
steps::tests::steps_10000005
steps::tests::steps_11250075
steps::tests::steps_more_than_10000000
steps::tests::steps_much_more_than_10000000
"},
);
}
Expand Down Expand Up @@ -1145,9 +1141,9 @@ fn call_nonexistent_selector() {
output,
indoc! {r"
Collected 1 test(s) from nonexistent_selector package
Running 1 test(s) from tests/
[PASS] nonexistent_selector_integrationtest::test_contract::test_unwrapped_call_contract_syscall (gas: ~103)
Running 0 test(s) from src/
Running 1 test(s) from tests/
[PASS] nonexistent_selector_integrationtest::test_contract::test_unwrapped_call_contract_syscall [..]
Tests: 1 passed, 0 failed, 0 skipped, 0 ignored, 0 filtered out
"},
);
Expand Down
36 changes: 18 additions & 18 deletions crates/forge/tests/e2e/steps.rs
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ fn should_allow_less_than_default() {

Collected 4 test(s) from steps package
Running 4 test(s) from src/
[FAIL] steps::tests::steps_570030
[FAIL] steps::tests::steps_more_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[FAIL] steps::tests::steps_11250075
[FAIL] steps::tests::steps_less_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[FAIL] steps::tests::steps_10000005
[FAIL] steps::tests::steps_much_more_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[FAIL] steps::tests::steps_9999990
[FAIL] steps::tests::steps_much_less_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

Tests: 0 passed, 4 failed, 0 skipped, 0 ignored, 0 filtered out

Failures:
steps::tests::steps_570030
steps::tests::steps_11250075
steps::tests::steps_10000005
steps::tests::steps_9999990
steps::tests::steps_more_than_10000000
steps::tests::steps_less_than_10000000
steps::tests::steps_much_more_than_10000000
steps::tests::steps_much_less_than_10000000
"
),
);
Expand All @@ -70,10 +70,10 @@ fn should_allow_more_than_10m() {

Collected 4 test(s) from steps package
Running 4 test(s) from src/
[PASS] steps::tests::steps_570030 (gas: ~1521)
[PASS] steps::tests::steps_10000005 (gas: ~26667)
[PASS] steps::tests::steps_9999990 (gas: ~26667)
[PASS] steps::tests::steps_11250075 (gas: ~30001)
[PASS] steps::tests::steps_much_less_than_10000000 [..]
ddoktorski marked this conversation as resolved.
Show resolved Hide resolved
[PASS] steps::tests::steps_more_than_10000000 [..]
[PASS] steps::tests::steps_less_than_10000000 [..]
[PASS] steps::tests::steps_much_more_than_10000000 [..]
Tests: 4 passed, 0 failed, 0 skipped, 0 ignored, 0 filtered out
"
),
Expand All @@ -94,23 +94,23 @@ fn should_default_to_10m() {

Collected 4 test(s) from steps package
Running 4 test(s) from src/
[PASS] steps::tests::steps_570030 (gas: ~1521)
[FAIL] steps::tests::steps_10000005
[PASS] steps::tests::steps_much_less_than_10000000 [..]
[FAIL] steps::tests::steps_much_more_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[FAIL] steps::tests::steps_11250075
[FAIL] steps::tests::steps_more_than_10000000

Failure data:
Could not reach the end of the program. RunResources has no remaining steps.

[PASS] steps::tests::steps_9999990 (gas: ~26667)
[PASS] steps::tests::steps_less_than_10000000 [..]
Tests: 2 passed, 2 failed, 0 skipped, 0 ignored, 0 filtered out

Failures:
steps::tests::steps_10000005
steps::tests::steps_11250075
steps::tests::steps_much_more_than_10000000
steps::tests::steps_more_than_10000000
"
),
);
Expand Down
Loading