fn run_window_request(slot: Slot, nonce: Nonce) {
        let recycler = PacketBatchRecycler::default();
        solana_logger::setup();
        let ledger_path = get_tmp_ledger_path!();
        {
            let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap());
            let me = ContactInfo {
                id: solana_sdk::pubkey::new_rand(),
                gossip: socketaddr!("127.0.0.1:1234"),
                tvu: socketaddr!("127.0.0.1:1235"),
                tvu_forwards: socketaddr!("127.0.0.1:1236"),
                repair: socketaddr!("127.0.0.1:1237"),
                tpu: socketaddr!("127.0.0.1:1238"),
                tpu_forwards: socketaddr!("127.0.0.1:1239"),
                tpu_vote: socketaddr!("127.0.0.1:1240"),
                rpc: socketaddr!("127.0.0.1:1241"),
                rpc_pubsub: socketaddr!("127.0.0.1:1242"),
                serve_repair: socketaddr!("127.0.0.1:1243"),
                wallclock: 0,
                shred_version: 0,
            };
            let rv = ServeRepair::run_window_request(
                &recycler,
                &me,
                &socketaddr_any!(),
                Some(&blockstore),
                &me.id,
                slot,
                0,
                nonce,
            );
            assert!(rv.is_none());
            let shred = Shred::new_from_data(slot, 1, 1, None, false, false, 0, 2, 0);

            blockstore
                .insert_shreds(vec![shred], None, false)
                .expect("Expect successful ledger write");

            let index = 1;
            let rv = ServeRepair::run_window_request(
                &recycler,
                &me,
                &socketaddr_any!(),
                Some(&blockstore),
                &me.id,
                slot,
                index,
                nonce,
            )
            .expect("packets");
            let request = ShredRepairType::Shred(slot, index);
            verify_responses(&request, rv.packets.iter());
            let rv: Vec<Shred> = rv
                .packets
                .into_iter()
                .filter_map(|b| {
                    assert_eq!(repair_response::nonce(&b.data[..]).unwrap(), nonce);
                    Shred::new_from_serialized_shred(b.data.to_vec()).ok()
                })
                .collect();
            assert_eq!(rv[0].index(), 1);
            assert_eq!(rv[0].slot(), slot);
        }

        Blockstore::destroy(&ledger_path).expect("Expected successful database destruction");
    }
/// test window requests respond with the right shred, and do not overrun
test window requests respond with the right shred, and do not overrun
test window requests respond with the right shred and do not overrun
fn run_window_request(slot: Slot, nonce: Nonce) {
        let recycler = PacketBatchRecycler::default();
        solana_logger::setup();
        let ledger_path = get_tmp_ledger_path!();
        {
            let blockstore = Arc::new(Blockstore::open(&ledger_path).unwrap());
            let me = ContactInfo {
                id: solana_sdk::pubkey::new_rand(),
                gossip: socketaddr!("127.0.0.1:1234"),
                tvu: socketaddr!("127.0.0.1:1235"),
                tvu_forwards: socketaddr!("127.0.0.1:1236"),
                repair: socketaddr!("127.0.0.1:1237"),
                tpu: socketaddr!("127.0.0.1:1238"),
                tpu_forwards: socketaddr!("127.0.0.1:1239"),
                tpu_vote: socketaddr!("127.0.0.1:1240"),
                rpc: socketaddr!("127.0.0.1:1241"),
                rpc_pubsub: socketaddr!("127.0.0.1:1242"),
                serve_repair: socketaddr!("127.0.0.1:1243"),
                wallclock: 0,
                shred_version: 0,
            };
            let rv = ServeRepair::run_window_request(
                &recycler,
                &me,
                &socketaddr_any!(),
                Some(&blockstore),
                &me.id,
                slot,
                0,
                nonce,
            );
            assert!(rv.is_none());
            let shred = Shred::new_from_data(slot, 1, 1, None, false, false, 0, 2, 0);
            blockstore
                .insert_shreds(vec![shred], None, false)
                .expect("Expect successful ledger write");
            let index = 1;
            let rv = ServeRepair::run_window_request(
                &recycler,
                &me,
                &socketaddr_any!(),
                Some(&blockstore),
                &me.id,
                slot,
                index,
                nonce,
            )
            .expect("packets");
            let request = ShredRepairType::Shred(slot, index);
            verify_responses(&request, rv.packets.iter());
            let rv: Vec<Shred> = rv
                .packets
                .into_iter()
                .filter_map(|b| {
                    assert_eq!(repair_response::nonce(&b.data[..]).unwrap(), nonce);
                    Shred::new_from_serialized_shred(b.data.to_vec()).ok()
                })
                .collect();
            assert_eq!(rv[0].index(), 1);
            assert_eq!(rv[0].slot(), slot);
        }
        Blockstore::destroy(&ledger_path).expect("Expected successful database destruction");
    }
fn run_window_request ( slot : Slot , nonce : Nonce ) { let recycler = PacketBatchRecycler :: default ( ) ; solana_logger :: setup ( ) ; let ledger_path = get_tmp_ledger_path ! ( ) ; { let blockstore = Arc :: new ( Blockstore :: open ( & ledger_path ) . unwrap ( ) ) ; let me = ContactInfo { id : solana_sdk :: pubkey :: new_rand ( ) , gossip : socketaddr ! ( " " ) , tvu : socketaddr ! ( " " ) , tvu_forwards : socketaddr ! ( " " ) , repair : socketaddr ! ( " " ) , tpu : socketaddr ! ( " " ) , tpu_forwards : socketaddr ! ( " " ) , tpu_vote : socketaddr ! ( " " ) , rpc : socketaddr ! ( " " ) , rpc_pubsub : socketaddr ! ( " " ) , serve_repair : socketaddr ! ( " " ) , wallclock : 0 , shred_version : 0 , } ; let rv = ServeRepair :: run_window_request ( & recycler , & me , & socketaddr_any ! ( ) , Some ( & blockstore ) , & me . id , slot , 0 , nonce , ) ; assert ! ( rv is_none ( ) ) ; let shred = Shred :: new_from_data ( slot , 1 , 1 , None , false , false , 0 , 2 , 0 ) ; blockstore . insert_shreds ( vec ! [ shred ] , None , false ) . expect ( " " ) ; let index = 1 ; let rv = ServeRepair :: run_window_request ( & recycler , & me , & socketaddr_any ! ( ) , Some ( & blockstore ) , & me . id , slot , index , nonce , ) . expect ( " " ) ; let request = ShredRepairType :: Shred ( slot , index ) ; verify_responses ( & request , rv . packets . iter ( ) ) ; let rv : Vec < Shred > = rv . packets . into_iter ( ) . filter_map ( | b | { assert_eq ! ( repair_response nonce ( b data [ ] ) unwrap ( ) nonce ) ; Shred :: new_from_serialized_shred ( b . data . to_vec ( ) ) . ok ( ) } ) . collect ( ) ; assert_eq ! ( rv [ 0 ] index ( ) 1 ) ; assert_eq ! ( rv [ 0 ] slot ( ) slot ) ; } Blockstore :: destroy ( & ledger_path ) . expect ( " " ) ; }
test window requests respond with the right shred, and do not overrun
test window requests respond with the right shred and do not overrun
slot
Slot
nonce
Nonce