Add BooleanBitfield struct

This commit is contained in:
Paul Hauner
2018-07-12 14:59:50 +10:00
parent 4c7b2eec2c
commit 5e362567e6
11 changed files with 161 additions and 17 deletions

View File

@@ -20,7 +20,7 @@ impl ActiveState {
Self {
height: 0,
randao: Sha256Digest::zero(),
ffg_voter_bitfield: Vec::new(),
ffg_voter_bitfield: Bitfield::new(),
recent_attesters: Vec::new(),
partial_crosslinks: Vec::new(),
total_skip_count: 0,
@@ -96,11 +96,11 @@ mod tests {
}
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let a = ActiveState {
height: 100,
randao: Sha256Digest::zero(),
ffg_voter_bitfield: Vec::new(),
ffg_voter_bitfield: Bitfield::new(),
recent_attesters: Vec::new(),
partial_crosslinks: Vec::new(),
total_skip_count: 99,

View File

@@ -14,7 +14,7 @@ impl AggregateVote {
Self {
shard_id: 0,
shard_block_hash: Sha256Digest::zero(),
notary_bitfield: Vec::new(),
notary_bitfield: Bitfield::new(),
aggregate_sig: AggregateSignature::new()
}
}
@@ -46,11 +46,11 @@ mod tests {
}
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let a = AggregateVote {
shard_id: 100,
shard_block_hash: Sha256Digest::zero(),
notary_bitfield: Vec::new(),
notary_bitfield: Bitfield::new(),
aggregate_sig: AggregateSignature::new()
};
let e = rlp::encode(&a);

View File

@@ -23,7 +23,7 @@ impl Block {
parent_hash: parent_hash,
skip_count: 0,
randao_reveal: randao_reveal,
attestation_bitfield: Vec::new(),
attestation_bitfield: Bitfield::new(),
attestation_aggregate_sig: AggregateSignature::new(),
shard_aggregate_votes: Vec::new(),
main_chain_ref: main_chain_ref,
@@ -147,12 +147,12 @@ mod tests {
}
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let b = Block {
parent_hash: Sha256Digest::zero(),
skip_count: 100,
randao_reveal: Sha256Digest::zero(),
attestation_bitfield: Vec::new(),
attestation_bitfield: Bitfield::new(),
attestation_aggregate_sig: AggregateSignature::new(),
shard_aggregate_votes: Vec::new(),
main_chain_ref: Sha256Digest::zero(),

View File

@@ -40,7 +40,7 @@ mod tests {
}
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let c = CrosslinkRecord {
epoch: 100,
hash: Sha256Digest::zero()

View File

@@ -92,7 +92,7 @@ mod tests {
use super::*;
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let a = CrystallizedState {
active_validators: Vec::new(),
queued_validators: Vec::new(),

View File

@@ -13,7 +13,7 @@ impl PartialCrosslinkRecord {
PartialCrosslinkRecord {
shard_id: shard_id,
shard_block_hash: shard_block_hash,
voter_bitfield: Vec::new()
voter_bitfield: Bitfield::new()
}
}
}
@@ -45,11 +45,11 @@ mod tests {
}
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let p = PartialCrosslinkRecord {
shard_id: 1,
shard_block_hash: Sha256Digest::zero(),
voter_bitfield: Vec::new()
voter_bitfield: Bitfield::new()
};
let e = rlp::encode(&p);
assert_eq!(e.len(), 35);

View File

@@ -37,7 +37,7 @@ mod tests {
use super::*;
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let index = 1;
let randao_commitment = Sha256Digest::zero();
let balance_delta = 99;

View File

@@ -81,7 +81,7 @@ mod tests {
}
#[test]
fn test_serialization() {
fn test_rlp_serialization() {
let keypair = get_dangerous_test_keypair();
let v = ValidatorRecord {
pubkey: keypair.public,