add asserts in spec::validatorset's unit test
This commit is contained in:
parent
f90802498f
commit
a0dd77ca01
@ -40,6 +40,10 @@ pub enum ValidatorSet {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
use uint::Uint;
|
||||||
|
use util::U256;
|
||||||
|
use hash::Address;
|
||||||
|
use util::hash::H160;
|
||||||
use spec::validator_set::ValidatorSet;
|
use spec::validator_set::ValidatorSet;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -58,6 +62,20 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}]"#;
|
}]"#;
|
||||||
|
|
||||||
let _deserialized: Vec<ValidatorSet> = serde_json::from_str(s).unwrap();
|
let deserialized: Vec<ValidatorSet> = serde_json::from_str(s).unwrap();
|
||||||
|
assert_eq!(deserialized.len(), 4);
|
||||||
|
|
||||||
|
assert_eq!(deserialized[0], ValidatorSet::List(vec![Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))]));
|
||||||
|
assert_eq!(deserialized[1], ValidatorSet::SafeContract(Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))));
|
||||||
|
assert_eq!(deserialized[2], ValidatorSet::Contract(Address(H160::from("0xc6d9d2cd449a754c494264e1809c50e34d64562b"))));
|
||||||
|
match deserialized[3] {
|
||||||
|
ValidatorSet::Multi(ref map) => {
|
||||||
|
assert_eq!(map.len(), 3);
|
||||||
|
assert!(map.contains_key(&Uint(U256::from(0))));
|
||||||
|
assert!(map.contains_key(&Uint(U256::from(10))));
|
||||||
|
assert!(map.contains_key(&Uint(U256::from(20))));
|
||||||
|
},
|
||||||
|
_ => assert!(false),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user