From 5c7c30cc4bb6d5f1528ab68f9b6983afdf88c715 Mon Sep 17 00:00:00 2001 From: Guanqun Lu Date: Sun, 14 May 2017 22:40:15 +0800 Subject: [PATCH] add asserts in spec param.rs --- json/src/spec/params.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index 31b5cf68a..d546ad86b 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -64,21 +64,27 @@ pub struct Params { #[cfg(test)] mod tests { use serde_json; + use uint::Uint; + use util::U256; use spec::params::Params; #[test] fn params_deserialization() { let s = r#"{ - "homesteadTransition": "0x118c30", "maximumExtraDataSize": "0x20", "networkID" : "0x1", "chainID" : "0x15", "subprotocolName" : "exp", "minGasLimit": "0x1388", - "accountStartNonce": "0x00" + "accountStartNonce": "0x01" }"#; - let _deserialized: Params = serde_json::from_str(s).unwrap(); - // TODO: validate all fields + let deserialized: Params = serde_json::from_str(s).unwrap(); + assert_eq!(deserialized.maximum_extra_data_size, Uint(U256::from(0x20))); + assert_eq!(deserialized.network_id, Uint(U256::from(0x1))); + assert_eq!(deserialized.chain_id, Some(Uint(U256::from(0x15)))); + assert_eq!(deserialized.subprotocol_name, Some("exp".to_owned())); + assert_eq!(deserialized.min_gas_limit, Uint(U256::from(0x1388))); + assert_eq!(deserialized.account_start_nonce, Some(Uint(U256::from(0x01)))); } }