From 205a5b9b428e5436cd2ccf824fc7c76b61fbf528 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Thu, 6 Jul 2023 13:50:20 -0700 Subject: [PATCH] add missing import and test more --- web3_proxy/src/config.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/web3_proxy/src/config.rs b/web3_proxy/src/config.rs index abdc3039..d69d7563 100644 --- a/web3_proxy/src/config.rs +++ b/web3_proxy/src/config.rs @@ -67,6 +67,7 @@ pub struct AppConfig { /// EVM chain id. 1 for ETH /// TODO: better type for chain_id? max of `u64::MAX / 2 - 36` + #[serde_inline_default(1u64)] pub chain_id: u64, /// Database is used for user data. @@ -299,14 +300,21 @@ impl Web3RpcConfig { #[cfg(test)] mod tests { - use super::Web3RpcConfig; + use super::{AppConfig, Web3RpcConfig}; + use serde_json::json; #[test] fn expected_app_defaults() { - let a: AppConfig = serde_json::from_str("{}").unwrap(); + let a: AppConfig = serde_json::from_value(json!({ + "chain_id": 1, + })).unwrap(); + + assert_eq!(a.min_synced_rpcs, 1); let b: AppConfig = Default::default(); + assert_eq!(b.min_synced_rpcs, 1); + assert_eq!(a, b); }