Move more params to the common section. (#6134)

* move common forks and parameters to common params

* port specs over to new format

* fix RPC tests
This commit is contained in:
Robert Habermeier
2017-07-31 12:34:29 +02:00
committed by Gav Wood
parent 9c5ef1f776
commit 003eef982b
55 changed files with 224 additions and 358 deletions

View File

@@ -17,25 +17,16 @@
//! Authority params deserialization.
use uint::Uint;
use hash::Address;
use super::ValidatorSet;
/// Authority params deserialization.
#[derive(Debug, PartialEq, Deserialize)]
pub struct AuthorityRoundParams {
/// Gas limit divisor.
#[serde(rename="gasLimitBoundDivisor")]
pub gas_limit_bound_divisor: Uint,
/// Block duration.
#[serde(rename="stepDuration")]
pub step_duration: Uint,
/// Valid authorities
pub validators: ValidatorSet,
/// Block reward.
#[serde(rename="blockReward")]
pub block_reward: Option<Uint>,
/// Address of the registrar contract.
pub registrar: Option<Address>,
/// Starting step. Determined automatically if not specified.
/// To be used for testing only.
#[serde(rename="startStep")]
@@ -43,9 +34,6 @@ pub struct AuthorityRoundParams {
/// Block at which score validation should start.
#[serde(rename="validateScoreTransition")]
pub validate_score_transition: Option<Uint>,
/// See main AuthorityRoundParams docs.
#[serde(rename="eip155Transition")]
pub eip155_transition: Option<Uint>,
/// Block from which monotonic steps start.
#[serde(rename="validateStepTransition")]
pub validate_step_transition: Option<Uint>,
@@ -63,9 +51,8 @@ pub struct AuthorityRound {
#[cfg(test)]
mod tests {
use bigint::prelude::{U256, H160};
use uint::Uint;
use util::U256;
use util::H160;
use serde_json;
use hash::Address;
use spec::validator_set::ValidatorSet;
@@ -75,26 +62,19 @@ mod tests {
fn authority_round_deserialization() {
let s = r#"{
"params": {
"gasLimitBoundDivisor": "0x0400",
"stepDuration": "0x02",
"validators": {
"list" : ["0xc6d9d2cd449a754c494264e1809c50e34d64562b"]
},
"blockReward": "0x50",
"startStep" : 24,
"eip155Transition": "0x42",
"validateStepTransition": 150
}
}"#;
let deserialized: AuthorityRound = serde_json::from_str(s).unwrap();
assert_eq!(deserialized.params.gas_limit_bound_divisor, Uint(U256::from(0x0400)));
assert_eq!(deserialized.params.step_duration, Uint(U256::from(0x02)));
assert_eq!(deserialized.params.validators, ValidatorSet::List(vec![Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))]));
assert_eq!(deserialized.params.block_reward, Some(Uint(U256::from(0x50))));
assert!(deserialized.params.registrar.is_none());
assert_eq!(deserialized.params.start_step, Some(Uint(U256::from(24))));
assert_eq!(deserialized.params.eip155_transition, Some(Uint(U256::from(0x42))));
assert_eq!(deserialized.params.immediate_transitions, None);
}
}