Skip to content

Commit 9434744

Browse files
authored
Don't fetch block numbers nor check rpc version for ignored tests (#3742)
<!-- Reference any GitHub issues resolved by this PR --> Closes #1637 ## Introduced changes Block number and RPC version for ignored tests is no longer being checked - `fork_config` returns `None` for ignored tests - `should_be_run` `IgnoredFilter::Ignored` match arm asserts that test case is ignored. ## 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`
1 parent 16091dc commit 9434744

File tree

6 files changed

+580
-63
lines changed

6 files changed

+580
-63
lines changed

crates/forge-runner/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::coverage_api::run_coverage;
22
use crate::forge_config::{ExecutionDataToSave, ForgeConfig};
3+
use crate::package_tests::TestCase;
34
use crate::running::{run_fuzz_test, run_test};
45
use crate::test_case_summary::TestCaseSummary;
56
use anyhow::Result;
@@ -56,7 +57,13 @@ const BUILTINS: [&str; 11] = [
5657
];
5758

5859
pub trait TestCaseFilter {
59-
fn should_be_run(&self, test_case: &TestCaseWithResolvedConfig) -> bool;
60+
fn should_be_run<T>(&self, test_case: &TestCase<T>) -> bool
61+
where
62+
T: TestCaseIsIgnored;
63+
}
64+
65+
pub trait TestCaseIsIgnored {
66+
fn is_ignored(&self) -> bool;
6067
}
6168

6269
pub fn maybe_save_trace_and_profile(

crates/forge-runner/src/package_tests/with_config.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use super::{TestCase, TestTarget};
2-
use crate::expected_result::{ExpectedPanicValue, ExpectedTestResult};
2+
use crate::{
3+
TestCaseIsIgnored,
4+
expected_result::{ExpectedPanicValue, ExpectedTestResult},
5+
};
36
use cheatnet::runtime_extensions::forge_config_extension::config::{
47
Expected, RawAvailableResourceBoundsConfig, RawForgeConfig, RawForkConfig, RawFuzzerConfig,
58
RawShouldPanicConfig,
@@ -22,6 +25,12 @@ pub struct TestCaseConfig {
2225
pub disable_predeployed_contracts: bool,
2326
}
2427

28+
impl TestCaseIsIgnored for TestCaseConfig {
29+
fn is_ignored(&self) -> bool {
30+
self.ignored
31+
}
32+
}
33+
2534
impl From<RawForgeConfig> for TestCaseConfig {
2635
fn from(value: RawForgeConfig) -> Self {
2736
Self {

crates/forge-runner/src/package_tests/with_config_resolved.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{TestCase, TestTarget};
2-
use crate::{expected_result::ExpectedTestResult, package_tests::TestDetails};
2+
use crate::{TestCaseIsIgnored, expected_result::ExpectedTestResult, package_tests::TestDetails};
33
use anyhow::Result;
44
use cairo_vm::types::program::Program;
55
use cheatnet::runtime_extensions::forge_config_extension::config::{
@@ -55,3 +55,9 @@ pub struct TestCaseResolvedConfig {
5555
pub fuzzer_config: Option<RawFuzzerConfig>,
5656
pub disable_predeployed_contracts: bool,
5757
}
58+
59+
impl TestCaseIsIgnored for TestCaseResolvedConfig {
60+
fn is_ignored(&self) -> bool {
61+
self.ignored
62+
}
63+
}

crates/forge/src/run_tests/package.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ async fn test_package_with_config_resolved(
136136
fork_targets: &[ForkTarget],
137137
block_number_map: &mut BlockNumberMap,
138138
forge_config: &ForgeConfig,
139+
tests_filter: &TestsFilter,
139140
) -> Result<Vec<TestTargetWithResolvedConfig>> {
140141
let mut test_targets_with_resolved_config = Vec::with_capacity(test_targets.len());
141142

@@ -145,7 +146,8 @@ async fn test_package_with_config_resolved(
145146
&forge_config.test_runner_config.tracked_resource,
146147
)?;
147148

148-
let test_target = resolve_config(test_target, fork_targets, block_number_map).await?;
149+
let test_target =
150+
resolve_config(test_target, fork_targets, block_number_map, tests_filter).await?;
149151

150152
test_targets_with_resolved_config.push(test_target);
151153
}
@@ -174,6 +176,7 @@ pub async fn run_for_package(
174176
&fork_targets,
175177
block_number_map,
176178
&forge_config,
179+
&tests_filter,
177180
)
178181
.await?;
179182
let all_tests = sum_test_cases(&test_targets);

0 commit comments

Comments
 (0)