-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(derive): payload builder tests (#106)
- Loading branch information
Showing
6 changed files
with
257 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Implements a mock [L2SystemConfigFetcher] for testing. | ||
use crate::{stages::attributes_queue::SystemConfigL2Fetcher, types::SystemConfig}; | ||
use alloy_primitives::B256; | ||
use hashbrown::HashMap; | ||
|
||
/// A mock implementation of the [`SystemConfigL2Fetcher`] for testing. | ||
#[derive(Debug, Default)] | ||
pub struct MockSystemConfigL2Fetcher { | ||
/// A map from [B256] block hash to a [SystemConfig]. | ||
pub system_configs: HashMap<B256, SystemConfig>, | ||
} | ||
|
||
impl MockSystemConfigL2Fetcher { | ||
/// Inserts a new system config into the mock fetcher with the given hash. | ||
pub fn insert(&mut self, hash: B256, config: SystemConfig) { | ||
self.system_configs.insert(hash, config); | ||
} | ||
|
||
/// Clears all system configs from the mock fetcher. | ||
pub fn clear(&mut self) { | ||
self.system_configs.clear(); | ||
} | ||
} | ||
|
||
impl SystemConfigL2Fetcher for MockSystemConfigL2Fetcher { | ||
fn system_config_by_l2_hash(&self, hash: B256) -> anyhow::Result<SystemConfig> { | ||
self.system_configs | ||
.get(&hash) | ||
.cloned() | ||
.ok_or_else(|| anyhow::anyhow!("system config not found")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters