Skip to content

Commit 1ac2709

Browse files
Thibrackkawuladdoktorskicptartur
authored
Feat: add information about the ability to use --max-n-steps (#2869)
<!-- Reference any GitHub issues resolved by this PR --> Closes #2853 ## Introduced changes <!-- A brief description of the changes --> - Updated error to suggest using “--max-n-steps” in case of cairo_vm error ## Checklist <!-- Make sure all of these are complete --> - [x] Linked relevant issue - [x] Updated relevant documentation - [x] Added relevant tests - [x] Performed self-review of the code - [x] Added changes to `CHANGELOG.md` --------- Co-authored-by: kkawula <[email protected]> Co-authored-by: ddoktorski <[email protected]> Co-authored-by: Artur Michałek <[email protected]>
1 parent 0077504 commit 1ac2709

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Forge
1111

12+
#### Added
13+
14+
- Added a suggestion for using the `--max-n-steps` flag when the Cairo VM returns the error: `Could not reach the end of the program. RunResources has no remaining steps`.
15+
16+
### Forge
17+
1218
#### Fixed
1319

1420
- coverage validation now supports comments in `Scarb.toml`

crates/forge-runner/src/running.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use blockifier::execution::entry_point::EntryPointExecutionContext;
88
use blockifier::state::cached_state::CachedState;
99
use cairo_lang_runner::{RunResult, SierraCasmRunner};
1010
use cairo_vm::vm::errors::cairo_run_errors::CairoRunError;
11+
use cairo_vm::vm::errors::vm_errors::VirtualMachineError;
1112
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
1213
use camino::{Utf8Path, Utf8PathBuf};
1314
use casm::{get_assembled_program, run_assembled_program};
@@ -306,22 +307,31 @@ fn extract_test_case_summary(
306307
versioned_program_path,
307308
),
308309
// CairoRunError comes from VirtualMachineError which may come from HintException that originates in TestExecutionSyscallHandler
309-
Err(error) => TestCaseSummary::Failed {
310-
name: case.name.clone(),
311-
msg: Some(format!(
310+
Err(error) => {
311+
let mut message = format!(
312312
"\n {}\n",
313313
error.to_string().replace(" Custom Hint Error: ", "\n ")
314-
))
315-
.map(|msg| {
316-
add_backtrace_footer(
317-
msg,
318-
contracts_data,
319-
&result_with_info.encountered_errors,
320-
)
321-
}),
322-
arguments: args,
323-
test_statistics: (),
324-
},
314+
);
315+
if let CairoRunError::VirtualMachine(VirtualMachineError::UnfinishedExecution) =
316+
*error
317+
{
318+
message.push_str(
319+
"\n Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps",
320+
);
321+
}
322+
TestCaseSummary::Failed {
323+
name: case.name.clone(),
324+
msg: Some(message).map(|msg| {
325+
add_backtrace_footer(
326+
msg,
327+
contracts_data,
328+
&result_with_info.encountered_errors,
329+
)
330+
}),
331+
arguments: args,
332+
test_statistics: (),
333+
}
334+
}
325335
}
326336
}
327337
// `ForkStateReader.get_block_info`, `get_fork_state_reader, `calculate_used_gas` may return an error

crates/forge/tests/e2e/running.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,13 @@ fn incompatible_snforge_std_version_warning() {
10521052
10531053
Failure data:
10541054
Could not reach the end of the program. RunResources has no remaining steps.
1055+
Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps
10551056
10561057
[FAIL] steps::tests::steps_much_more_than_10000000
10571058
10581059
Failure data:
10591060
Could not reach the end of the program. RunResources has no remaining steps.
1061+
Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps
10601062
10611063
[PASS] steps::tests::steps_less_than_10000000 [..]
10621064
Tests: 2 passed, 2 failed, 0 skipped, 0 ignored, 0 filtered out

crates/forge/tests/e2e/steps.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,25 @@ fn should_allow_less_than_default() {
2626
2727
Failure data:
2828
Could not reach the end of the program. RunResources has no remaining steps.
29+
Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps
2930
3031
[FAIL] steps::tests::steps_less_than_10000000
3132
3233
Failure data:
3334
Could not reach the end of the program. RunResources has no remaining steps.
35+
Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps
3436
3537
[FAIL] steps::tests::steps_much_more_than_10000000
3638
3739
Failure data:
3840
Could not reach the end of the program. RunResources has no remaining steps.
41+
Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps
3942
4043
[FAIL] steps::tests::steps_much_less_than_10000000
4144
4245
Failure data:
4346
Could not reach the end of the program. RunResources has no remaining steps.
47+
Suggestion: Consider using the flag `--max-n-steps` to increase allowed limit of steps
4448
4549
Tests: 0 passed, 4 failed, 0 skipped, 0 ignored, 0 filtered out
4650

0 commit comments

Comments
 (0)