-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexis Asseman <[email protected]>
- Loading branch information
Showing
16 changed files
with
444 additions
and
171 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...7f92c832fb3ae514c27a3293cb899e5e246d.json → ...36dbfc396116aa2a93bb379029672701cef8.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
.sqlx/query-a39cf8e5d4b670583e8a2b0af20c270c3db62668e2df5a2b7e7a2fac0ef69405.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,44 @@ | ||
/// Load a hashmap of sender addresses and their corresponding aggregator endpoints | ||
/// from a yaml file. We're using serde_yaml. | ||
use std::collections::HashMap; | ||
use std::fs::File; | ||
use std::io::BufReader; | ||
use std::path::PathBuf; | ||
|
||
use alloy_primitives::Address; | ||
|
||
/// Load a hashmap of sender addresses and their corresponding aggregator endpoints | ||
/// from a yaml file. We're using serde_yaml. | ||
pub fn load_aggregator_endpoints(file_path: PathBuf) -> HashMap<Address, String> { | ||
let file = File::open(file_path).unwrap(); | ||
let reader = BufReader::new(file); | ||
let endpoints: HashMap<Address, String> = serde_yaml::from_reader(reader).unwrap(); | ||
endpoints | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::{io::Write, str::FromStr}; | ||
|
||
use super::*; | ||
|
||
/// Test that we can load the aggregator endpoints from a yaml file. | ||
/// The test is going to create a temporary yaml file using tempfile, load it, and | ||
/// check that the endpoints are loaded correctly. | ||
#[test] | ||
fn test_load_aggregator_endpoints() { | ||
let named_temp_file = tempfile::NamedTempFile::new().unwrap(); | ||
let mut temp_file = named_temp_file.reopen().unwrap(); | ||
let yaml = r#" | ||
0xdeadbeefcafebabedeadbeefcafebabedeadbeef: https://example.com/aggregate-receipts | ||
0x0123456789abcdef0123456789abcdef01234567: https://other.example.com/aggregate-receipts | ||
"#; | ||
temp_file.write_all(yaml.as_bytes()).unwrap(); | ||
let endpoints = load_aggregator_endpoints(named_temp_file.path().to_path_buf()); | ||
assert_eq!( | ||
endpoints | ||
.get(&Address::from_str("0xdeadbeefcafebabedeadbeefcafebabedeadbeef").unwrap()), | ||
Some(&"https://example.com/aggregate-receipts".to_string()) | ||
); | ||
} | ||
} |
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
Oops, something went wrong.