Add RLP encoding to RecentProposerRecord
This commit is contained in:
parent
64a9455f87
commit
909d624730
@ -1,3 +1,4 @@
|
||||
use super::rlp::{ RlpStream, Encodable };
|
||||
use super::utils::types::*;
|
||||
|
||||
pub struct RecentPropserRecord {
|
||||
@ -17,3 +18,34 @@ impl RecentPropserRecord {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* RLP Encoding
|
||||
*/
|
||||
impl Encodable for RecentPropserRecord {
|
||||
fn rlp_append(&self, s: &mut RlpStream) {
|
||||
s.append(&self.index);
|
||||
s.append(&self.randao_commitment);
|
||||
s.append(&self.balance_delta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::super::rlp;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_serialization() {
|
||||
let index = 1;
|
||||
let randao_commitment = Sha256Digest::zero();
|
||||
let balance_delta = 99;
|
||||
let r = RecentPropserRecord::new(index, randao_commitment, balance_delta);
|
||||
let e = rlp::encode(&r);
|
||||
assert_eq!(e[0], 1);
|
||||
assert_eq!(e[1], 160);
|
||||
assert_eq!(e[2..34], [0; 32]);
|
||||
assert_eq!(e[34], 99);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user