pricing { linear: {} }

This commit is contained in:
debris
2016-03-18 22:54:36 +01:00
parent e4ec80941c
commit 79aa8570d0
11 changed files with 42 additions and 49 deletions

View File

@@ -36,7 +36,7 @@ mod tests {
fn account_deserialization() {
let s = r#"{
"balance": "1",
"builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } }
"builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } }
}"#;
let _deserialized: Account = serde_json::from_str(s).unwrap();
// TODO: validate all fields

View File

@@ -16,8 +16,6 @@
//! Spec builtin deserialization.
use serde::de::{Deserialize, Deserializer};
/// Linear pricing.
#[derive(Debug, PartialEq, Deserialize)]
pub struct Linear {
@@ -26,20 +24,13 @@ pub struct Linear {
}
/// Pricing variants.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Deserialize)]
pub enum Pricing {
/// Linear pricing.
#[serde(rename="linear")]
Linear(Linear),
}
impl Deserialize for Pricing {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: Deserializer {
Deserialize::deserialize(deserializer).map(Pricing::Linear)
}
}
/// Spec builtin.
#[derive(Debug, PartialEq, Deserialize)]
pub struct Builtin {
@@ -56,7 +47,7 @@ mod tests {
fn builtin_deserialization() {
let s = r#"{
"name": "ecrecover",
"pricing": { "base": 3000, "word": 0 }
"pricing": { "linear": { "base": 3000, "word": 0 } }
}"#;
let _deserialized: Builtin = serde_json::from_str(s).unwrap();
// TODO: validate all fields

View File

@@ -71,10 +71,10 @@ mod tests {
"enode://b1217cbaa440e35ed471157123fe468e19e8b5ad5bedb4b1fdbcbdab6fb2f5ed3e95dd9c24a22a79fdb2352204cea207df27d92bfd21bfd41545e8b16f637499@104.44.138.37:30303"
],
"accounts": {
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "base": 3000, "word": 0 } } },
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "base": 60, "word": 12 } } },
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "base": 600, "word": 120 } } },
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "base": 15, "word": 3 } } },
"0000000000000000000000000000000000000001": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ecrecover", "pricing": { "linear": { "base": 3000, "word": 0 } } } },
"0000000000000000000000000000000000000002": { "balance": "1", "nonce": "1048576", "builtin": { "name": "sha256", "pricing": { "linear": { "base": 60, "word": 12 } } } },
"0000000000000000000000000000000000000003": { "balance": "1", "nonce": "1048576", "builtin": { "name": "ripemd160", "pricing": { "linear": { "base": 600, "word": 120 } } } },
"0000000000000000000000000000000000000004": { "balance": "1", "nonce": "1048576", "builtin": { "name": "identity", "pricing": { "linear": { "base": 15, "word": 3 } } } },
"102e61f5d8f9bc71d0ad4a084df4e65e05ce0e1c": { "balance": "1606938044258990275541962092341162602522202993782792835301376", "nonce": "1048576" }
}
}"#;