restructure test_broadcast_last_tick test to check for is_last_blob

This commit is contained in:
Carl 2019-02-12 14:00:10 -08:00 committed by Grimes
parent a1b5ea9cb1
commit 3c8a8640aa
1 changed files with 15 additions and 15 deletions

View File

@ -8,7 +8,6 @@ use solana::entry::{reconstruct_entries_from_blobs, Entry};
use solana::fullnode::{new_bank_from_ledger, Fullnode, FullnodeConfig, FullnodeReturnType}; use solana::fullnode::{new_bank_from_ledger, Fullnode, FullnodeConfig, FullnodeReturnType};
use solana::gossip_service::{converge, make_listening_node}; use solana::gossip_service::{converge, make_listening_node};
use solana::leader_scheduler::{make_active_set_entries, LeaderSchedulerConfig}; use solana::leader_scheduler::{make_active_set_entries, LeaderSchedulerConfig};
use solana::packet::SharedBlob;
use solana::result; use solana::result;
use solana::service::Service; use solana::service::Service;
use solana::thin_client::{poll_gossip_for_leader, retry_get_balance}; use solana::thin_client::{poll_gossip_for_leader, retry_get_balance};
@ -1650,23 +1649,24 @@ fn test_broadcast_last_tick() {
info!("Check that the nodes got the last broadcasted blob"); info!("Check that the nodes got the last broadcasted blob");
for (_, receiver) in blob_fetch_stages.iter() { for (_, receiver) in blob_fetch_stages.iter() {
info!("Checking a node..."); info!("Checking a node...");
let mut last_tick_blob: SharedBlob = SharedBlob::default(); let mut blobs = vec![];
while let Ok(new_blobs) = receiver.try_recv() { while let Ok(new_blobs) = receiver.try_recv() {
let last_blob = new_blobs blobs.extend(new_blobs);
.into_iter()
.find(|b| b.read().unwrap().index() == last_tick_entry_index as u64);
if let Some(last_blob) = last_blob {
last_tick_blob = last_blob;
break;
} }
}
debug!("last_tick_blob: {:?}", last_tick_blob); for b in blobs {
assert!(last_tick_blob.read().unwrap().is_last_blob()); let b_r = b.read().unwrap();
let actual_last_tick = if b_r.index() == last_tick_entry_index as u64 {
&reconstruct_entries_from_blobs(vec![&*last_tick_blob.read().unwrap()]) assert!(b_r.is_last_blob());
debug!("last_tick_blob: {:?}", b_r);
let actual_last_tick = &reconstruct_entries_from_blobs(vec![&*b_r])
.expect("Expected to be able to reconstruct entries from blob") .expect("Expected to be able to reconstruct entries from blob")
.0[0]; .0[0];
assert_eq!(actual_last_tick, expected_last_tick); assert_eq!(actual_last_tick, expected_last_tick);
} else {
assert!(!b_r.is_last_blob());
}
}
} }
info!("done!"); info!("done!");