Skip to content

Commit 61a9338

Browse files
committed
context -> test_context in Cheatcodes config
1 parent c589110 commit 61a9338

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

crates/cheatcodes/src/fs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Cheatcode for closeFileCall {
9797
let Self { path } = self;
9898
let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?;
9999

100-
state.context.opened_read_files.remove(&path);
100+
state.test_context.opened_read_files.remove(&path);
101101

102102
Ok(Default::default())
103103
}
@@ -167,7 +167,7 @@ impl Cheatcode for readLineCall {
167167
let path = state.config.ensure_path_allowed(path, FsAccessKind::Read)?;
168168

169169
// Get reader for previously opened file to continue reading OR initialize new reader
170-
let reader = match state.context.opened_read_files.entry(path.clone()) {
170+
let reader = match state.test_context.opened_read_files.entry(path.clone()) {
171171
Entry::Occupied(entry) => entry.into_mut(),
172172
Entry::Vacant(entry) => entry.insert(BufReader::new(fs::open(path)?)),
173173
};
@@ -212,7 +212,7 @@ impl Cheatcode for removeFileCall {
212212
state.config.ensure_not_foundry_toml(&path)?;
213213

214214
// also remove from the set if opened previously
215-
state.context.opened_read_files.remove(&path);
215+
state.test_context.opened_read_files.remove(&path);
216216

217217
if state.fs_commit {
218218
fs::remove_file(&path)?;

crates/cheatcodes/src/inspector.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ pub trait CheatcodesExecutor {
8989
/// [revm::Inspector].
9090
fn get_inspector<'a>(&'a mut self, cheats: &'a mut Cheatcodes) -> Box<dyn InspectorExt + 'a>;
9191

92-
/// Obtains [revm::Evm] instance and executes the given CREATE frame.
9392
/// Obtains [revm::Evm] instance and executes the given CREATE frame.
9493
fn exec_create(
9594
&mut self,
@@ -222,19 +221,19 @@ macro_rules! try_or_return {
222221

223222
/// Contains additional, test specific resources that should be kept for the duration of the test
224223
#[derive(Debug, Default)]
225-
pub struct Context {
224+
pub struct TestContext {
226225
/// Buffered readers for files opened for reading (path => BufReader mapping)
227226
pub opened_read_files: HashMap<PathBuf, BufReader<File>>,
228227
}
229228

230229
/// Every time we clone `Context`, we want it to be empty
231-
impl Clone for Context {
230+
impl Clone for TestContext {
232231
fn clone(&self) -> Self {
233232
Default::default()
234233
}
235234
}
236235

237-
impl Context {
236+
impl TestContext {
238237
/// Clears the context.
239238
#[inline]
240239
pub fn clear(&mut self) {
@@ -484,7 +483,7 @@ pub struct Cheatcodes {
484483
pub config: Arc<CheatsConfig>,
485484

486485
/// Test-scoped context holding data that needs to be reset every test run
487-
pub context: Context,
486+
pub test_context: TestContext,
488487

489488
/// Whether to commit FS changes such as file creations, writes and deletes.
490489
/// Used to prevent duplicate changes file executing non-committing calls.
@@ -568,7 +567,7 @@ impl Cheatcodes {
568567
broadcast: Default::default(),
569568
broadcastable_transactions: Default::default(),
570569
access_list: Default::default(),
571-
context: Default::default(),
570+
test_context: Default::default(),
572571
serialized_jsons: Default::default(),
573572
eth_deals: Default::default(),
574573
gas_metering: Default::default(),

crates/cheatcodes/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extern crate tracing;
1717

1818
use alloy_primitives::Address;
1919
use foundry_evm_core::{backend::DatabaseExt, evm::FoundryEvmContext};
20-
2120
use spec::Status;
2221

2322
pub use config::CheatsConfig;

0 commit comments

Comments
 (0)