Add slot_history for slashing (#7589)

* Add slot_history for slashing

* fixup

* fixup
This commit is contained in:
Rob Walker
2019-12-23 12:23:45 -08:00
committed by GitHub
parent 352a367570
commit 120c8f244c
15 changed files with 209 additions and 53 deletions

View File

@@ -39,8 +39,9 @@ impl<'a> FromIterator<&'a Hash> for RecentBlockhashes {
}
impl Sysvar for RecentBlockhashes {
fn biggest() -> Self {
RecentBlockhashes(vec![Hash::default(); MAX_ENTRIES])
fn size_of() -> usize {
// hard-coded so that we don't have to construct an empty
1032 // golden, update if MAX_ENTRIES changes
}
}
@@ -86,6 +87,15 @@ mod tests {
use super::*;
use crate::hash::Hash;
#[test]
fn test_size_of() {
assert_eq!(
bincode::serialized_size(&RecentBlockhashes(vec![Hash::default(); MAX_ENTRIES]))
.unwrap() as usize,
RecentBlockhashes::size_of()
);
}
#[test]
fn test_create_account_empty() {
let account = create_account_with_data(42, vec![].into_iter());