-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathcheats.rs
82 lines (65 loc) · 2.63 KB
/
cheats.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Forge tests for cheatcodes.
use crate::{
config::*,
test_helpers::{
ForgeTestData, RE_PATH_SEPARATOR, TEST_DATA_DEFAULT, TEST_DATA_MULTI_VERSION,
TEST_DATA_PARIS,
},
};
use alloy_primitives::U256;
use foundry_config::{fs_permissions::PathPermission, FsPermissions};
use foundry_test_utils::Filter;
/// Executes all cheat code tests but not fork cheat codes or tests that require isolation mode or
/// specific seed.
async fn test_cheats_local(test_data: &ForgeTestData) {
let mut filter = Filter::new(".*", ".*", &format!(".*cheats{RE_PATH_SEPARATOR}*"))
.exclude_paths("Fork")
.exclude_contracts("(Isolated|WithSeed)");
// Exclude FFI tests on Windows because no `echo`, and file tests that expect certain file paths
if cfg!(windows) {
filter = filter.exclude_tests("(Ffi|File|Line|Root)");
}
if cfg!(feature = "isolate-by-default") {
filter = filter.exclude_contracts("(LastCallGasDefaultTest|MockFunctionTest|WithSeed)");
}
let runner = test_data.runner_with(|config| {
config.fs_permissions = FsPermissions::new(vec![PathPermission::read_write("./")]);
});
TestConfig::with_filter(runner, filter).run().await;
}
/// Executes subset of all cheat code tests in isolation mode.
async fn test_cheats_local_isolated(test_data: &ForgeTestData) {
let filter = Filter::new(".*", ".*(Isolated)", &format!(".*cheats{RE_PATH_SEPARATOR}*"));
let runner = test_data.runner_with(|config| {
config.isolate = true;
});
TestConfig::with_filter(runner, filter).run().await;
}
/// Executes subset of all cheat code tests using a specific seed.
async fn test_cheats_local_with_seed(test_data: &ForgeTestData) {
let filter = Filter::new(".*", ".*(WithSeed)", &format!(".*cheats{RE_PATH_SEPARATOR}*"));
let runner = test_data.runner_with(|config| {
config.fuzz.seed = Some(U256::from(100));
});
TestConfig::with_filter(runner, filter).run().await;
}
#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_local_default() {
test_cheats_local(&TEST_DATA_DEFAULT).await
}
#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_local_default_isolated() {
test_cheats_local_isolated(&TEST_DATA_DEFAULT).await
}
#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_local_default_with_seed() {
test_cheats_local_with_seed(&TEST_DATA_DEFAULT).await
}
#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_local_multi_version() {
test_cheats_local(&TEST_DATA_MULTI_VERSION).await
}
#[tokio::test(flavor = "multi_thread")]
async fn test_cheats_local_paris() {
test_cheats_local(&TEST_DATA_PARIS).await
}