From 2e288777ac205fb28ec3a97625754de6457e59d7 Mon Sep 17 00:00:00 2001 From: refcell Date: Wed, 4 Sep 2024 10:31:58 -0400 Subject: [PATCH] feat(primitives): system config tests --- Cargo.lock | 1 + crates/primitives/Cargo.toml | 1 + crates/primitives/src/system_config.rs | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b02f51f..9c2e600 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1442,6 +1442,7 @@ dependencies = [ "arbitrary", "arbtest", "serde", + "serde_json", "serde_repr", ] diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index db9232f..cdfcf6e 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -28,6 +28,7 @@ arbitrary = { workspace = true, optional = true } [dev-dependencies] arbtest.workspace = true arbitrary.workspace = true +serde_json.workspace = true alloy-primitives = { workspace = true, features = ["arbitrary"] } [features] diff --git a/crates/primitives/src/system_config.rs b/crates/primitives/src/system_config.rs index 3a9fc4b..d79ab01 100644 --- a/crates/primitives/src/system_config.rs +++ b/crates/primitives/src/system_config.rs @@ -269,6 +269,24 @@ mod test { } } + #[test] + fn test_system_config_serde() { + let sc_str = r#"{ + "batcherAddr": "0x6887246668a3b87F54DeB3b94Ba47a6f63F32985", + "overhead": "0x00000000000000000000000000000000000000000000000000000000000000bc", + "scalar": "0x00000000000000000000000000000000000000000000000000000000000a6fe0", + "gasLimit": 30000000 + }"#; + let system_config: SystemConfig = serde_json::from_str(sc_str).unwrap(); + assert_eq!( + system_config.batcher_address, + address!("6887246668a3b87F54DeB3b94Ba47a6f63F32985") + ); + assert_eq!(system_config.overhead, U256::from(0xbc)); + assert_eq!(system_config.scalar, U256::from(0xa6fe0)); + assert_eq!(system_config.gas_limit, 30000000); + } + #[test] fn test_system_config_update_batcher_log() { const UPDATE_TYPE: B256 =