Skip to content

Commit c50f330

Browse files
committed
address comment
1 parent 11344f8 commit c50f330

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

crates/node/src/test_utils/fixture.rs

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -520,29 +520,35 @@ impl TestFixtureBuilder {
520520
&mut self.config
521521
}
522522

523-
/// Enable Anvil with the default state file (`./tests/testdata/anvil_state.json`).
524-
pub fn with_anvil(mut self) -> Self {
525-
self.anvil_config.enabled = true;
526-
self.anvil_config.state_path = Some(PathBuf::from("./tests/testdata/anvil_state.json"));
527-
self
528-
}
529-
530-
/// Enable Anvil with a custom state file.
531-
pub fn with_anvil_custom_state(mut self, path: impl Into<PathBuf>) -> Self {
523+
/// Enable Anvil with optional configuration.
524+
///
525+
/// # Parameters
526+
/// - `state_path`: Optional path to Anvil state file. Defaults to `./tests/testdata/anvil_state.json` if `None`.
527+
/// - `chain_id`: Optional chain ID for Anvil. If `None`, Anvil uses its default.
528+
/// - `block_time`: Optional block time in seconds. If `None`, Anvil uses its default.
529+
///
530+
/// # Examples
531+
/// ```ignore
532+
/// // Use default state file and default Anvil settings
533+
/// builder.with_anvil(None, None, None)
534+
///
535+
/// // Use default state file with custom chain ID
536+
/// builder.with_anvil(None, Some(22222222), None)
537+
///
538+
/// // Use custom state file with custom chain ID and block time
539+
/// builder.with_anvil(Some(PathBuf::from("custom_state.json")), Some(22222222), Some(1))
540+
/// ```
541+
pub fn with_anvil(
542+
mut self,
543+
state_path: Option<PathBuf>,
544+
chain_id: Option<u64>,
545+
block_time: Option<u64>,
546+
) -> Self {
532547
self.anvil_config.enabled = true;
533-
self.anvil_config.state_path = Some(path.into());
534-
self
535-
}
536-
537-
/// Set the chain ID for Anvil.
538-
pub const fn with_anvil_chain_id(mut self, chain_id: u64) -> Self {
539-
self.anvil_config.chain_id = Some(chain_id);
540-
self
541-
}
542-
543-
/// Set the block time for Anvil (in seconds).
544-
pub const fn with_anvil_block_time(mut self, block_time: u64) -> Self {
545-
self.anvil_config.block_time = Some(block_time);
548+
self.anvil_config.state_path = state_path
549+
.or_else(|| Some(PathBuf::from("./tests/testdata/anvil_state.json")));
550+
self.anvil_config.chain_id = chain_id;
551+
self.anvil_config.block_time = block_time;
546552
self
547553
}
548554

crates/node/tests/l1_sync.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ async fn test_l1_sync_batch_commit() -> eyre::Result<()> {
101101
let mut fixture = TestFixture::builder()
102102
.followers(1)
103103
.skip_l1_synced_notifications() // Prevents automatic L1Synced, simulates initial sync
104-
.with_anvil()
105-
.with_anvil_chain_id(22222222)
104+
.with_anvil(None, Some(22222222), None)
106105
.build()
107106
.await?;
108107

@@ -171,8 +170,7 @@ async fn test_l1_sync_batch_finalized() -> eyre::Result<()> {
171170
let mut fixture = TestFixture::builder()
172171
.followers(1)
173172
.skip_l1_synced_notifications()
174-
.with_anvil()
175-
.with_anvil_chain_id(22222222)
173+
.with_anvil(None, Some(22222222), None)
176174
.build()
177175
.await?;
178176

@@ -295,8 +293,7 @@ async fn test_l1_sync_batch_revert() -> eyre::Result<()> {
295293
let mut fixture = TestFixture::builder()
296294
.followers(1)
297295
.skip_l1_synced_notifications()
298-
.with_anvil()
299-
.with_anvil_chain_id(22222222)
296+
.with_anvil(None, Some(22222222), None)
300297
.build()
301298
.await?;
302299

@@ -370,8 +367,7 @@ async fn test_l1_reorg_batch_commit() -> eyre::Result<()> {
370367
let mut fixture = TestFixture::builder()
371368
.followers(1)
372369
.skip_l1_synced_notifications()
373-
.with_anvil()
374-
.with_anvil_chain_id(22222222)
370+
.with_anvil(None, Some(22222222), None)
375371
.build()
376372
.await?;
377373

@@ -454,8 +450,7 @@ async fn test_l1_reorg_batch_finalized() -> eyre::Result<()> {
454450
let mut fixture = TestFixture::builder()
455451
.followers(1)
456452
.skip_l1_synced_notifications()
457-
.with_anvil()
458-
.with_anvil_chain_id(22222222)
453+
.with_anvil(None, Some(22222222), None)
459454
.build()
460455
.await?;
461456

@@ -534,8 +529,7 @@ async fn test_l1_reorg_batch_revert() -> eyre::Result<()> {
534529
let mut fixture = TestFixture::builder()
535530
.followers(1)
536531
.skip_l1_synced_notifications()
537-
.with_anvil()
538-
.with_anvil_chain_id(22222222)
532+
.with_anvil(None, Some(22222222), None)
539533
.build()
540534
.await?;
541535

0 commit comments

Comments
 (0)