Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
prevent zero networkID, closes #8345
Browse files Browse the repository at this point in the history
Signed-off-by: Seun LanLege <[email protected]>
  • Loading branch information
seunlanlege committed Oct 16, 2018
1 parent ed34d1f commit 1a2f085
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions json/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct Params {

/// Network id.
#[serde(rename="networkID")]
#[serde(deserialize_with="uint::validate_non_zero")]
pub network_id: Uint,
/// Chain id.
#[serde(rename="chainID")]
Expand Down Expand Up @@ -208,4 +209,20 @@ mod tests {

let _deserialized: Params = serde_json::from_str(s).unwrap();
}

#[test]
#[should_panic(expected = "a non-zero value")]
fn test_non_zero_network_id() {
let s = r#"{
"maximumExtraDataSize": "0x20",
"networkID" : "0x0",
"subprotocolName" : "exp",
"minGasLimit": "0x1388",
"accountStartNonce": "0x01",
"gasLimitBoundDivisor": "0x20",
"maxCodeSize": "0x1000"
}"#;

let _deserialized: Params = serde_json::from_str(s).unwrap();
}
}

0 comments on commit 1a2f085

Please sign in to comment.