Start working on u64 json issue

This commit is contained in:
Paul Hauner 2019-09-02 13:21:53 +10:00
parent d4bf1390c9
commit d05c2d4110
No known key found for this signature in database
GPG Key ID: 5E2CFF9B75FA63DF
4 changed files with 16 additions and 3 deletions

View File

@ -31,3 +31,4 @@ tree_hash_derive = "0.2"
[dev-dependencies] [dev-dependencies]
env_logger = "0.6.0" env_logger = "0.6.0"
serde_json = "^1.0"

View File

@ -9,7 +9,7 @@ fn default_values() {
let cache = CommitteeCache::default(); let cache = CommitteeCache::default();
assert_eq!(cache.is_initialized_at(Epoch::new(0)), false); assert_eq!(cache.is_initialized_at(Epoch::new(0)), false);
assert_eq!(cache.active_validator_indices(), &[]); assert!(&cache.active_validator_indices().is_empty());
assert_eq!(cache.get_crosslink_committee_for_shard(0), None); assert_eq!(cache.get_crosslink_committee_for_shard(0), None);
assert_eq!(cache.get_attestation_duties(0), None); assert_eq!(cache.get_attestation_duties(0), None);
assert_eq!(cache.active_validator_count(), 0); assert_eq!(cache.active_validator_count(), 0);

View File

@ -191,4 +191,16 @@ mod epoch_tests {
Epoch::from_ssz_bytes(&max_epoch.as_ssz_bytes()).unwrap() Epoch::from_ssz_bytes(&max_epoch.as_ssz_bytes()).unwrap()
); );
} }
#[test]
fn epoch_max_value_json() {
let x: Epoch = Epoch::from(u64::max_value());
let json = serde_json::to_string(&x).expect("should json encode");
assert_eq!(&json, "18446744073709552000");
assert_eq!(
serde_json::from_str::<Epoch>(&json).expect("should json decode"),
x
);
}
} }

View File

@ -39,15 +39,15 @@ impl TestingProposerSlashingBuilder {
..header_1.clone() ..header_1.clone()
}; };
let epoch = slot.epoch(T::slots_per_epoch());
header_1.signature = { header_1.signature = {
let message = header_1.signed_root(); let message = header_1.signed_root();
let epoch = slot.epoch(T::slots_per_epoch());
signer(proposer_index, &message[..], epoch, Domain::BeaconProposer) signer(proposer_index, &message[..], epoch, Domain::BeaconProposer)
}; };
header_2.signature = { header_2.signature = {
let message = header_2.signed_root(); let message = header_2.signed_root();
let epoch = slot.epoch(T::slots_per_epoch());
signer(proposer_index, &message[..], epoch, Domain::BeaconProposer) signer(proposer_index, &message[..], epoch, Domain::BeaconProposer)
}; };