fn check_dead_fork<F>(shred_to_insert: F) -> result::Result<(), BlockstoreProcessorError>
    where
        F: Fn(&Keypair, Arc<Bank>) -> Vec<Shred>,
    {
        let ledger_path = get_tmp_ledger_path!();
        let (replay_vote_sender, _replay_vote_receiver) = unbounded();
        let res = {
            let blockstore = Arc::new(
                Blockstore::open(&ledger_path)
                    .expect("Expected to be able to open database ledger"),
            );
            let GenesisConfigInfo {
                mut genesis_config,
                mint_keypair,
                ..
            } = create_genesis_config(1000);
            genesis_config.poh_config.hashes_per_tick = Some(2);
            let bank_forks = BankForks::new(Bank::new(&genesis_config));
            let bank0 = bank_forks.working_bank();
            let mut progress = ProgressMap::default();
            let last_blockhash = bank0.last_blockhash();
            let mut bank0_progress = progress.entry(bank0.slot()).or_insert_with(|| {
                ForkProgress::new(last_blockhash, None, DuplicateStats::default(), None, 0, 0)
            });
            let shreds = shred_to_insert(&mint_keypair, bank0.clone());
            blockstore.insert_shreds(shreds, None, false).unwrap();
            let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::default()));
            let bank_forks = Arc::new(RwLock::new(bank_forks));
            let exit = Arc::new(AtomicBool::new(false));
            let res = ReplayStage::replay_blockstore_into_bank(
                &bank0,
                &blockstore,
                &mut bank0_progress,
                None,
                &replay_vote_sender,
                &&VerifyRecyclers::default(),
            );

            let subscriptions = Arc::new(RpcSubscriptions::new(
                &exit,
                bank_forks.clone(),
                block_commitment_cache,
                OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
            ));
            if let Err(err) = &res {
                ReplayStage::mark_dead_slot(
                    &blockstore,
                    &bank0,
                    0,
                    err,
                    &subscriptions,
                    &BTreeMap::new(),
                    &HashMap::new(),
                    &HashMap::new(),
                    &mut progress,
                    &mut HeaviestSubtreeForkChoice::new(0),
                );
            }

            // Check that the erroring bank was marked as dead in the progress map
            assert!(progress
                .get(&bank0.slot())
                .map(|b| b.is_dead)
                .unwrap_or(false));

            // Check that the erroring bank was marked as dead in blockstore
            assert!(blockstore.is_dead(bank0.slot()));
            res.map(|_| ())
        };
        let _ignored = remove_dir_all(&ledger_path);
        res
    }
// Given a shred and a fatal expected error, check that replaying that shred causes causes the fork to be
// marked as dead. Returns the error for caller to verify.
Given a shred and a fatal expected error, check that replaying that shred causes causes the fork to be
marked as dead. Returns the error for caller to verify.
Given a shred and a fatal expected error check that replaying that shred causes causes the fork to be marked as dead . Returns the error for caller to verify .
fn check_dead_fork<F>(shred_to_insert: F) -> result::Result<(), BlockstoreProcessorError>
    where
        F: Fn(&Keypair, Arc<Bank>) -> Vec<Shred>,
    {
        let ledger_path = get_tmp_ledger_path!();
        let (replay_vote_sender, _replay_vote_receiver) = unbounded();
        let res = {
            let blockstore = Arc::new(
                Blockstore::open(&ledger_path)
                    .expect("Expected to be able to open database ledger"),
            );
            let GenesisConfigInfo {
                mut genesis_config,
                mint_keypair,
                ..
            } = create_genesis_config(1000);
            genesis_config.poh_config.hashes_per_tick = Some(2);
            let bank_forks = BankForks::new(Bank::new(&genesis_config));
            let bank0 = bank_forks.working_bank();
            let mut progress = ProgressMap::default();
            let last_blockhash = bank0.last_blockhash();
            let mut bank0_progress = progress.entry(bank0.slot()).or_insert_with(|| {
                ForkProgress::new(last_blockhash, None, DuplicateStats::default(), None, 0, 0)
            });
            let shreds = shred_to_insert(&mint_keypair, bank0.clone());
            blockstore.insert_shreds(shreds, None, false).unwrap();
            let block_commitment_cache = Arc::new(RwLock::new(BlockCommitmentCache::default()));
            let bank_forks = Arc::new(RwLock::new(bank_forks));
            let exit = Arc::new(AtomicBool::new(false));
            let res = ReplayStage::replay_blockstore_into_bank(
                &bank0,
                &blockstore,
                &mut bank0_progress,
                None,
                &replay_vote_sender,
                &&VerifyRecyclers::default(),
            );
            let subscriptions = Arc::new(RpcSubscriptions::new(
                &exit,
                bank_forks.clone(),
                block_commitment_cache,
                OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
            ));
            if let Err(err) = &res {
                ReplayStage::mark_dead_slot(
                    &blockstore,
                    &bank0,
                    0,
                    err,
                    &subscriptions,
                    &BTreeMap::new(),
                    &HashMap::new(),
                    &HashMap::new(),
                    &mut progress,
                    &mut HeaviestSubtreeForkChoice::new(0),
                );
            }
            // Check that the erroring bank was marked as dead in the progress map
            assert!(progress
                .get(&bank0.slot())
                .map(|b| b.is_dead)
                .unwrap_or(false));
            // Check that the erroring bank was marked as dead in blockstore
            assert!(blockstore.is_dead(bank0.slot()));
            res.map(|_| ())
        };
        let _ignored = remove_dir_all(&ledger_path);
        res
    }
fn check_dead_fork < F > ( shred_to_insert : F ) -> result :: Result < ( ) , BlockstoreProcessorError > where F : Fn ( & Keypair , Arc < Bank > ) -> Vec < Shred > , { let ledger_path = get_tmp_ledger_path ! ( ) ; let ( replay_vote_sender , _replay_vote_receiver ) = unbounded ( ) ; let res = { let blockstore = Arc :: new ( Blockstore :: open ( & ledger_path ) . expect ( " " ) , ) ; let GenesisConfigInfo { mut genesis_config , mint_keypair , .. } = create_genesis_config ( 1000 ) ; genesis_config . poh_config . hashes_per_tick = Some ( 2 ) ; let bank_forks = BankForks :: new ( Bank :: new ( & genesis_config ) ) ; let bank0 = bank_forks . working_bank ( ) ; let mut progress = ProgressMap :: default ( ) ; let last_blockhash = bank0 . last_blockhash ( ) ; let mut bank0_progress = progress . entry ( bank0 . slot ( ) ) . or_insert_with ( | | { ForkProgress :: new ( last_blockhash , None , DuplicateStats :: default ( ) , None , 0 , 0 ) } ) ; let shreds = shred_to_insert ( & mint_keypair , bank0 . clone ( ) ) ; blockstore . insert_shreds ( shreds , None , false ) . unwrap ( ) ; let block_commitment_cache = Arc :: new ( RwLock :: new ( BlockCommitmentCache :: default ( ) ) ) ; let bank_forks = Arc :: new ( RwLock :: new ( bank_forks ) ) ; let exit = Arc :: new ( AtomicBool :: new ( false ) ) ; let res = ReplayStage :: replay_blockstore_into_bank ( & bank0 , & blockstore , & mut bank0_progress , None , & replay_vote_sender , & & VerifyRecyclers :: default ( ) , ) ; let subscriptions = Arc :: new ( RpcSubscriptions :: new ( & exit , bank_forks . clone ( ) , block_commitment_cache , OptimisticallyConfirmedBank :: locked_from_bank_forks_root ( & bank_forks ) , ) ) ; if let Err ( err ) = & res { ReplayStage :: mark_dead_slot ( & blockstore , & bank0 , 0 , err , & subscriptions , & BTreeMap :: new ( ) , & HashMap :: new ( ) , & HashMap :: new ( ) , & mut progress , & mut HeaviestSubtreeForkChoice :: new ( 0 ) , ) ; } // Check that the erroring bank was marked as dead in the progress map assert ! ( progress get ( bank0 slot ( ) ) map ( b b is_dead ) unwrap_or ( false ) ) ; // Check that the erroring bank was marked as dead in blockstore assert ! ( blockstore is_dead ( bank0 slot ( ) ) ) ; res . map ( | _ | ( ) ) } ; let _ignored = remove_dir_all ( & ledger_path ) ; res }
Given a shred and a fatal expected error, check that replaying that shred causes causes the fork to be
marked as dead.
Given a shred and a fatal expected error check that replaying that shred causes causes the fork to be marked as dead .
shred_to_insert
F
shred_to_insert
F