Skip to content

Commit

Permalink
Make serve_repair tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Czabaniuk committed May 20, 2021
1 parent 9875ab8 commit 83f2de7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/repair_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn repair_response_packet(
nonce: Nonce,
) -> Option<Packet> {
let shred = blockstore
.get_data_shred(slot, shred_index)
.get_data_shred_padded(slot, shred_index)
.expect("Blockstore could not get data shred");
shred
.map(|shred| repair_response_packet_from_shred(shred, dest, nonce))
Expand Down
14 changes: 11 additions & 3 deletions core/src/serve_repair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,10 @@ mod tests {
.into_iter()
.filter_map(|b| {
assert_eq!(repair_response::nonce(&b.data[..]).unwrap(), nonce);
Shred::new_from_serialized_shred(b.data.to_vec()).ok()
use solana_ledger::shred::SHRED_PAYLOAD_SIZE;
let mut serialized_shred = vec![0; SHRED_PAYLOAD_SIZE];
serialized_shred.copy_from_slice(&b.data[..SHRED_PAYLOAD_SIZE]);
Shred::new_from_serialized_shred(serialized_shred).ok()
})
.collect();
assert!(!rv.is_empty());
Expand Down Expand Up @@ -749,7 +752,10 @@ mod tests {
.into_iter()
.filter_map(|b| {
assert_eq!(repair_response::nonce(&b.data[..]).unwrap(), nonce);
Shred::new_from_serialized_shred(b.data.to_vec()).ok()
use solana_ledger::shred::SHRED_PAYLOAD_SIZE;
let mut serialized_shred = vec![0; SHRED_PAYLOAD_SIZE];
serialized_shred.copy_from_slice(&b.data[..SHRED_PAYLOAD_SIZE]);
Shred::new_from_serialized_shred(serialized_shred).ok()
})
.collect();
assert_eq!(rv[0].index(), 1);
Expand Down Expand Up @@ -1112,7 +1118,9 @@ mod tests {

fn verify_responses<'a>(request: &RepairType, packets: impl Iterator<Item = &'a Packet>) {
for packet in packets {
let shred_payload = packet.data.to_vec();
use solana_ledger::shred::SHRED_PAYLOAD_SIZE;
let mut shred_payload = vec![0; SHRED_PAYLOAD_SIZE];
shred_payload.copy_from_slice(&packet.data[..SHRED_PAYLOAD_SIZE]);
let shred = Shred::new_from_serialized_shred(shred_payload).unwrap();
request.verify_response(&shred);
}
Expand Down

0 comments on commit 83f2de7

Please sign in to comment.